Merge pull request #8337 from meshtastic/develop

Develop to master merge
This commit is contained in:
Ben Meadors
2025-10-13 20:51:52 -05:00
committed by GitHub
128 changed files with 814 additions and 1092 deletions
-56
View File
@@ -88,62 +88,6 @@ jobs:
if: ${{ !contains(github.ref_name, 'event/') && github.event_name != 'workflow_dispatch' || !contains(github.ref_name, 'event/') && inputs.arch == 'native' }} if: ${{ !contains(github.ref_name, 'event/') && github.event_name != 'workflow_dispatch' || !contains(github.ref_name, 'event/') && inputs.arch == 'native' }}
uses: ./.github/workflows/test_native.yml uses: ./.github/workflows/test_native.yml
docker-deb-amd64:
if: ${{ github.event_name != 'workflow_dispatch' || inputs.arch == 'native' }}
uses: ./.github/workflows/docker_build.yml
with:
distro: debian
platform: linux/amd64
runs-on: ubuntu-24.04
push: false
docker-deb-amd64-tft:
if: ${{ github.event_name != 'workflow_dispatch' || inputs.arch == 'native' }}
uses: ./.github/workflows/docker_build.yml
with:
distro: debian
platform: linux/amd64
runs-on: ubuntu-24.04
push: false
pio_env: native-tft
docker-alp-amd64:
if: ${{ github.event_name != 'workflow_dispatch' || inputs.arch == 'native' }}
uses: ./.github/workflows/docker_build.yml
with:
distro: alpine
platform: linux/amd64
runs-on: ubuntu-24.04
push: false
docker-alp-amd64-tft:
if: ${{ github.event_name != 'workflow_dispatch' || inputs.arch == 'native' }}
uses: ./.github/workflows/docker_build.yml
with:
distro: alpine
platform: linux/amd64
runs-on: ubuntu-24.04
push: false
pio_env: native-tft
docker-deb-arm64:
if: ${{ github.event_name != 'workflow_dispatch' || inputs.arch == 'native' }}
uses: ./.github/workflows/docker_build.yml
with:
distro: debian
platform: linux/arm64
runs-on: ubuntu-24.04-arm
push: false
docker-deb-armv7:
if: ${{ github.event_name != 'workflow_dispatch' || inputs.arch == 'native' }}
uses: ./.github/workflows/docker_build.yml
with:
distro: debian
platform: linux/arm/v7
runs-on: ubuntu-24.04-arm
push: false
gather-artifacts: gather-artifacts:
permissions: permissions:
contents: write contents: write
-56
View File
@@ -106,62 +106,6 @@ jobs:
if: ${{ !contains(github.ref_name, 'event/') && github.event_name != 'workflow_dispatch' || !contains(github.ref_name, 'event/') && inputs.arch == 'native' && inputs.target != '' }} if: ${{ !contains(github.ref_name, 'event/') && github.event_name != 'workflow_dispatch' || !contains(github.ref_name, 'event/') && inputs.arch == 'native' && inputs.target != '' }}
uses: ./.github/workflows/test_native.yml uses: ./.github/workflows/test_native.yml
docker-deb-amd64:
if: ${{ inputs.target != '' && inputs.arch == 'native' }}
uses: ./.github/workflows/docker_build.yml
with:
distro: debian
platform: linux/amd64
runs-on: ubuntu-24.04
push: false
docker-deb-amd64-tft:
if: ${{ inputs.target != '' && inputs.arch == 'native' }}
uses: ./.github/workflows/docker_build.yml
with:
distro: debian
platform: linux/amd64
runs-on: ubuntu-24.04
push: false
pio_env: native-tft
docker-alp-amd64:
if: ${{ inputs.target != '' && inputs.arch == 'native' }}
uses: ./.github/workflows/docker_build.yml
with:
distro: alpine
platform: linux/amd64
runs-on: ubuntu-24.04
push: false
docker-alp-amd64-tft:
if: ${{ inputs.target != '' && inputs.arch == 'native' }}
uses: ./.github/workflows/docker_build.yml
with:
distro: alpine
platform: linux/amd64
runs-on: ubuntu-24.04
push: false
pio_env: native-tft
docker-deb-arm64:
if: ${{ inputs.target != '' && inputs.arch == 'native' }}
uses: ./.github/workflows/docker_build.yml
with:
distro: debian
platform: linux/arm64
runs-on: ubuntu-24.04-arm
push: false
docker-deb-armv7:
if: ${{ inputs.target != '' && inputs.arch == 'native' }}
uses: ./.github/workflows/docker_build.yml
with:
distro: debian
platform: linux/arm/v7
runs-on: ubuntu-24.04-arm
push: false
gather-artifacts: gather-artifacts:
permissions: permissions:
contents: write contents: write
+18 -58
View File
@@ -27,7 +27,6 @@ on:
jobs: jobs:
setup: setup:
if: github.repository == 'meshtastic/firmware'
strategy: strategy:
fail-fast: true fail-fast: true
matrix: matrix:
@@ -42,10 +41,6 @@ jobs:
python-version: 3.x python-version: 3.x
cache: pip cache: pip
- run: pip install -U platformio - run: pip install -U platformio
- name: Uncomment build epoch
shell: bash
run: |
sed -i 's/#-DBUILD_EPOCH=$UNIX_TIME/-DBUILD_EPOCH=$UNIX_TIME/' platformio.ini
- name: Generate matrix - name: Generate matrix
id: jsonStep id: jsonStep
run: | run: |
@@ -62,7 +57,6 @@ jobs:
check: ${{ steps.jsonStep.outputs.check }} check: ${{ steps.jsonStep.outputs.check }}
version: version:
if: github.repository == 'meshtastic/firmware'
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v5
@@ -125,60 +119,26 @@ jobs:
if: ${{ !contains(github.ref_name, 'event/') && github.repository == 'meshtastic/firmware' }} if: ${{ !contains(github.ref_name, 'event/') && github.repository == 'meshtastic/firmware' }}
uses: ./.github/workflows/test_native.yml uses: ./.github/workflows/test_native.yml
docker-deb-amd64: docker:
if: github.repository == 'meshtastic/firmware' strategy:
fail-fast: false
matrix:
distro: [debian, alpine]
platform: [linux/amd64, linux/arm64, linux/arm/v7]
pio_env: [native, native-tft]
exclude:
- distro: alpine
platform: linux/arm/v7
- pio_env: native-tft
platform: linux/arm64
- pio_env: native-tft
platform: linux/arm/v7
uses: ./.github/workflows/docker_build.yml uses: ./.github/workflows/docker_build.yml
with: with:
distro: debian distro: ${{ matrix.distro }}
platform: linux/amd64 platform: ${{ matrix.platform }}
runs-on: ubuntu-24.04 runs-on: ${{ contains(matrix.platform, 'arm') && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
push: false pio_env: ${{ matrix.pio_env }}
docker-deb-amd64-tft:
if: github.repository == 'meshtastic/firmware'
uses: ./.github/workflows/docker_build.yml
with:
distro: debian
platform: linux/amd64
runs-on: ubuntu-24.04
push: false
pio_env: native-tft
docker-alp-amd64:
if: github.repository == 'meshtastic/firmware'
uses: ./.github/workflows/docker_build.yml
with:
distro: alpine
platform: linux/amd64
runs-on: ubuntu-24.04
push: false
docker-alp-amd64-tft:
if: github.repository == 'meshtastic/firmware'
uses: ./.github/workflows/docker_build.yml
with:
distro: alpine
platform: linux/amd64
runs-on: ubuntu-24.04
push: false
pio_env: native-tft
docker-deb-arm64:
if: github.repository == 'meshtastic/firmware'
uses: ./.github/workflows/docker_build.yml
with:
distro: debian
platform: linux/arm64
runs-on: ubuntu-24.04-arm
push: false
docker-deb-armv7:
if: github.repository == 'meshtastic/firmware'
uses: ./.github/workflows/docker_build.yml
with:
distro: debian
platform: linux/arm/v7
runs-on: ubuntu-24.04-arm
push: false push: false
gather-artifacts: gather-artifacts:
+18 -46
View File
@@ -99,54 +99,26 @@ jobs:
if: ${{ !contains(github.ref_name, 'event/') }} if: ${{ !contains(github.ref_name, 'event/') }}
uses: ./.github/workflows/test_native.yml uses: ./.github/workflows/test_native.yml
docker-deb-amd64: docker:
strategy:
fail-fast: false
matrix:
distro: [debian, alpine]
platform: [linux/amd64, linux/arm64, linux/arm/v7]
pio_env: [native, native-tft]
exclude:
- distro: alpine
platform: linux/arm/v7
- pio_env: native-tft
platform: linux/arm64
- pio_env: native-tft
platform: linux/arm/v7
uses: ./.github/workflows/docker_build.yml uses: ./.github/workflows/docker_build.yml
with: with:
distro: debian distro: ${{ matrix.distro }}
platform: linux/amd64 platform: ${{ matrix.platform }}
runs-on: ubuntu-24.04 runs-on: ${{ contains(matrix.platform, 'arm') && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
push: false pio_env: ${{ matrix.pio_env }}
docker-deb-amd64-tft:
uses: ./.github/workflows/docker_build.yml
with:
distro: debian
platform: linux/amd64
runs-on: ubuntu-24.04
push: false
pio_env: native-tft
docker-alp-amd64:
uses: ./.github/workflows/docker_build.yml
with:
distro: alpine
platform: linux/amd64
runs-on: ubuntu-24.04
push: false
docker-alp-amd64-tft:
uses: ./.github/workflows/docker_build.yml
with:
distro: alpine
platform: linux/amd64
runs-on: ubuntu-24.04
push: false
pio_env: native-tft
docker-deb-arm64:
uses: ./.github/workflows/docker_build.yml
with:
distro: debian
platform: linux/arm64
runs-on: ubuntu-24.04-arm
push: false
docker-deb-armv7:
uses: ./.github/workflows/docker_build.yml
with:
distro: debian
platform: linux/arm/v7
runs-on: ubuntu-24.04-arm
push: false push: false
gather-artifacts: gather-artifacts:
+116
View File
@@ -0,0 +1,116 @@
#!/bin/bash
# Script to cancel all running GitHub Actions workflows
# Requires GitHub CLI (gh) to be installed and authenticated
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if gh CLI is installed
if ! command -v gh &> /dev/null; then
print_error "GitHub CLI (gh) is not installed. Please install it first:"
echo " brew install gh"
echo " Or visit: https://cli.github.com/"
exit 1
fi
# Check if authenticated
if ! gh auth status &> /dev/null; then
print_error "GitHub CLI is not authenticated. Please run:"
echo " gh auth login"
exit 1
fi
# Get repository info
REPO=$(gh repo view --json owner,name -q '.owner.login + "/" + .name')
if [[ -z "$REPO" ]]; then
print_error "Could not determine repository. Make sure you're in a GitHub repository."
exit 1
fi
print_status "Working with repository: $REPO"
# Get all active workflows (both queued and in-progress)
print_status "Fetching active workflows (queued and in-progress)..."
QUEUED_WORKFLOWS=$(gh run list --status queued --json databaseId,displayTitle,headBranch,status --limit 100)
IN_PROGRESS_WORKFLOWS=$(gh run list --status in_progress --json databaseId,displayTitle,headBranch,status --limit 100)
# Combine both lists
ALL_WORKFLOWS=$(echo "$QUEUED_WORKFLOWS $IN_PROGRESS_WORKFLOWS" | jq -s 'add | unique_by(.databaseId)')
if [[ "$ALL_WORKFLOWS" == "[]" ]]; then
print_status "No active workflows found."
exit 0
fi
# Parse and display active workflows
echo
print_warning "Found active workflows:"
echo "$ALL_WORKFLOWS" | jq -r '.[] | " - \(.displayTitle) (Branch: \(.headBranch), Status: \(.status), ID: \(.databaseId))"'
echo
read -p "Do you want to cancel ALL these workflows? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
print_status "Cancelled by user."
exit 0
fi
# Cancel each workflow
print_status "Cancelling workflows..."
CANCELLED_COUNT=0
FAILED_COUNT=0
while IFS= read -r WORKFLOW_ID; do
if [[ -n "$WORKFLOW_ID" ]]; then
print_status "Cancelling workflow ID: $WORKFLOW_ID"
if gh run cancel "$WORKFLOW_ID" 2>/dev/null; then
((CANCELLED_COUNT++))
else
print_error "Failed to cancel workflow ID: $WORKFLOW_ID"
((FAILED_COUNT++))
fi
fi
done < <(echo "$ALL_WORKFLOWS" | jq -r '.[].databaseId')
echo
print_status "Summary:"
echo " - Cancelled: $CANCELLED_COUNT workflows"
if [[ $FAILED_COUNT -gt 0 ]]; then
echo " - Failed: $FAILED_COUNT workflows"
fi
print_status "Done!"
# Optional: Show remaining active workflows
echo
print_status "Checking for any remaining active workflows..."
REMAINING_QUEUED=$(gh run list --status queued --json databaseId --limit 10)
REMAINING_IN_PROGRESS=$(gh run list --status in_progress --json databaseId --limit 10)
REMAINING_ALL=$(echo "$REMAINING_QUEUED $REMAINING_IN_PROGRESS" | jq -s 'add | unique_by(.databaseId)')
if [[ "$REMAINING_ALL" == "[]" ]]; then
print_status "All workflows successfully cancelled."
else
REMAINING_COUNT=$(echo "$REMAINING_ALL" | jq '. | length')
print_warning "Still $REMAINING_COUNT workflows active (may take a moment to update status)"
fi
+1
View File
@@ -562,6 +562,7 @@ class AnalogBatteryLevel : public HasBatteryLevel
config.power.device_battery_ina_address) { config.power.device_battery_ina_address) {
if (!ina226Sensor.isInitialized()) if (!ina226Sensor.isInitialized())
return ina226Sensor.runOnce() > 0; return ina226Sensor.runOnce() > 0;
return ina226Sensor.isRunning();
} else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA260].first == } else if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_INA260].first ==
config.power.device_battery_ina_address) { config.power.device_battery_ina_address) {
if (!ina260Sensor.isInitialized()) if (!ina260Sensor.isInitialized())
+16
View File
@@ -0,0 +1,16 @@
#include "ScanI2CConsumer.h"
#include <forward_list>
static std::forward_list<ScanI2CConsumer *> ScanI2CConsumers;
ScanI2CConsumer::ScanI2CConsumer()
{
ScanI2CConsumers.push_front(this);
}
void ScanI2CCompleted(ScanI2C *i2cScanner)
{
for (ScanI2CConsumer *consumer : ScanI2CConsumers) {
consumer->i2cScanFinished(i2cScanner);
}
}
+13
View File
@@ -0,0 +1,13 @@
#pragma once
#include "ScanI2C.h"
#include <stddef.h>
class ScanI2CConsumer
{
public:
ScanI2CConsumer();
virtual void i2cScanFinished(ScanI2C *i2cScanner) = 0;
};
void ScanI2CCompleted(ScanI2C *i2cScanner);
+3 -2
View File
@@ -378,7 +378,8 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
case SHT31_4x_ADDR: // same as OPT3001_ADDR_ALT case SHT31_4x_ADDR: // same as OPT3001_ADDR_ALT
case SHT31_4x_ADDR_ALT: // same as OPT3001_ADDR case SHT31_4x_ADDR_ALT: // same as OPT3001_ADDR
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x89), 2); registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x89), 2);
if (registerValue == 0x11a2 || registerValue == 0x11da || registerValue == 0x11f3 || registerValue == 0xe9c || registerValue == 0xc8d) { if (registerValue == 0x11a2 || registerValue == 0x11da || registerValue == 0x11f3 || registerValue == 0xe9c ||
registerValue == 0xc8d) {
type = SHT4X; type = SHT4X;
logFoundDevice("SHT4X", (uint8_t)addr.address); logFoundDevice("SHT4X", (uint8_t)addr.address);
} else if (getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x7E), 2) == 0x5449) { } else if (getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x7E), 2) == 0x5449) {
@@ -580,7 +581,7 @@ void ScanI2CTwoWire::scanPort(I2CPort port)
scanPort(port, nullptr, 0); scanPort(port, nullptr, 0);
} }
TwoWire *ScanI2CTwoWire::fetchI2CBus(ScanI2C::DeviceAddress address) const TwoWire *ScanI2CTwoWire::fetchI2CBus(ScanI2C::DeviceAddress address)
{ {
if (address.port == ScanI2C::I2CPort::WIRE) { if (address.port == ScanI2C::I2CPort::WIRE) {
return &Wire; return &Wire;
+2 -2
View File
@@ -23,12 +23,12 @@ class ScanI2CTwoWire : public ScanI2C
ScanI2C::FoundDevice find(ScanI2C::DeviceType) const override; ScanI2C::FoundDevice find(ScanI2C::DeviceType) const override;
TwoWire *fetchI2CBus(ScanI2C::DeviceAddress) const;
bool exists(ScanI2C::DeviceType) const override; bool exists(ScanI2C::DeviceType) const override;
size_t countDevices() const override; size_t countDevices() const override;
static TwoWire *fetchI2CBus(ScanI2C::DeviceAddress);
protected: protected:
FoundDevice firstOfOrNONE(size_t, DeviceType[]) const override; FoundDevice firstOfOrNONE(size_t, DeviceType[]) const override;
-11
View File
@@ -494,17 +494,6 @@ bool GPS::setup()
if (!didSerialInit) { if (!didSerialInit) {
int msglen = 0; int msglen = 0;
if (tx_gpio && gnssModel == GNSS_MODEL_UNKNOWN) { if (tx_gpio && gnssModel == GNSS_MODEL_UNKNOWN) {
#ifdef TRACKER_T1000_E
// add power up/down strategy, improve ag3335 detection success
digitalWrite(PIN_GPS_EN, LOW);
delay(500);
digitalWrite(GPS_VRTC_EN, LOW);
delay(1000);
digitalWrite(GPS_VRTC_EN, HIGH);
delay(500);
digitalWrite(PIN_GPS_EN, HIGH);
delay(1000);
#endif
if (probeTries < GPS_PROBETRIES) { if (probeTries < GPS_PROBETRIES) {
gnssModel = probe(serialSpeeds[speedSelect]); gnssModel = probe(serialSpeeds[speedSelect]);
if (gnssModel == GNSS_MODEL_UNKNOWN) { if (gnssModel == GNSS_MODEL_UNKNOWN) {
+39 -3
View File
@@ -762,6 +762,31 @@ void menuHandler::nodeListMenu()
screen->showOverlayBanner(bannerOptions); screen->showOverlayBanner(bannerOptions);
} }
void menuHandler::nodeNameLengthMenu()
{
enum OptionsNumbers { Back, Long, Short };
static const char *optionsArray[] = {"Back", "Long", "Short"};
BannerOverlayOptions bannerOptions;
bannerOptions.message = "Node Name Length";
bannerOptions.optionsArrayPtr = optionsArray;
bannerOptions.optionsCount = 3;
bannerOptions.bannerCallback = [](int selected) -> void {
if (selected == Long) {
// Set names to long
LOG_INFO("Setting names to long");
config.display.use_long_node_name = true;
} else if (selected == Short) {
// Set names to short
LOG_INFO("Setting names to short");
config.display.use_long_node_name = false;
} else if (selected == Back) {
menuQueue = screen_options_menu;
screen->runNow();
}
};
screen->showOverlayBanner(bannerOptions);
}
void menuHandler::resetNodeDBMenu() void menuHandler::resetNodeDBMenu()
{ {
static const char *optionsArray[] = {"Back", "Confirm"}; static const char *optionsArray[] = {"Back", "Confirm"};
@@ -1304,11 +1329,16 @@ void menuHandler::screenOptionsMenu()
hasSupportBrightness = false; hasSupportBrightness = false;
#endif #endif
enum optionsNumbers { Back, Brightness, ScreenColor }; enum optionsNumbers { Back, NodeNameLength, Brightness, ScreenColor };
static const char *optionsArray[4] = {"Back"}; static const char *optionsArray[5] = {"Back"};
static int optionsEnumArray[4] = {Back}; static int optionsEnumArray[5] = {Back};
int options = 1; int options = 1;
#if defined(T_DECK) || defined(T_LORA_PAGER)
optionsArray[options] = "Show Long/Short Name";
optionsEnumArray[options++] = NodeNameLength;
#endif
// Only show brightness for B&W displays // Only show brightness for B&W displays
if (hasSupportBrightness) { if (hasSupportBrightness) {
optionsArray[options] = "Brightness"; optionsArray[options] = "Brightness";
@@ -1333,6 +1363,9 @@ void menuHandler::screenOptionsMenu()
} else if (selected == ScreenColor) { } else if (selected == ScreenColor) {
menuHandler::menuQueue = menuHandler::tftcolormenupicker; menuHandler::menuQueue = menuHandler::tftcolormenupicker;
screen->runNow(); screen->runNow();
} else if (selected == NodeNameLength) {
menuHandler::menuQueue = menuHandler::node_name_length_menu;
screen->runNow();
} else { } else {
menuQueue = system_base_menu; menuQueue = system_base_menu;
screen->runNow(); screen->runNow();
@@ -1610,6 +1643,9 @@ void menuHandler::handleMenuSwitch(OLEDDisplay *display)
case brightness_picker: case brightness_picker:
BrightnessPickerMenu(); BrightnessPickerMenu();
break; break;
case node_name_length_menu:
nodeNameLengthMenu();
break;
case reboot_menu: case reboot_menu:
rebootMenu(); rebootMenu();
break; break;
+2
View File
@@ -43,6 +43,7 @@ class menuHandler
key_verification_final_prompt, key_verification_final_prompt,
trace_route_menu, trace_route_menu,
throttle_message, throttle_message,
node_name_length_menu,
FrameToggles FrameToggles
}; };
static screenMenus menuQueue; static screenMenus menuQueue;
@@ -85,6 +86,7 @@ class menuHandler
static void notificationsMenu(); static void notificationsMenu();
static void screenOptionsMenu(); static void screenOptionsMenu();
static void powerMenu(); static void powerMenu();
static void nodeNameLengthMenu();
static void FrameToggles_menu(); static void FrameToggles_menu();
static void textMessageMenu(); static void textMessageMenu();
+19 -13
View File
@@ -55,26 +55,32 @@ static int scrollIndex = 0;
const char *getSafeNodeName(meshtastic_NodeInfoLite *node) const char *getSafeNodeName(meshtastic_NodeInfoLite *node)
{ {
const char *name = NULL;
static char nodeName[16] = "?"; static char nodeName[16] = "?";
if (node->has_user && strlen(node->user.short_name) > 0) { if (config.display.use_long_node_name == true) {
bool valid = true; if (node->has_user && strlen(node->user.long_name) > 0) {
const char *name = node->user.short_name; name = node->user.long_name;
for (size_t i = 0; i < strlen(name); i++) {
uint8_t c = (uint8_t)name[i];
if (c < 32 || c > 126) {
valid = false;
break;
}
}
if (valid) {
strncpy(nodeName, name, sizeof(nodeName) - 1);
nodeName[sizeof(nodeName) - 1] = '\0';
} else { } else {
snprintf(nodeName, sizeof(nodeName), "(%04X)", (uint16_t)(node->num & 0xFFFF)); snprintf(nodeName, sizeof(nodeName), "(%04X)", (uint16_t)(node->num & 0xFFFF));
} }
} else {
if (node->has_user && strlen(node->user.short_name) > 0) {
name = node->user.short_name;
} else {
snprintf(nodeName, sizeof(nodeName), "(%04X)", (uint16_t)(node->num & 0xFFFF));
}
}
// Use sanitizeString() function and copy directly into nodeName
std::string sanitized_name = sanitizeString(name ? name : "");
if (!sanitized_name.empty()) {
strncpy(nodeName, sanitized_name.c_str(), sizeof(nodeName) - 1);
nodeName[sizeof(nodeName) - 1] = '\0';
} else { } else {
snprintf(nodeName, sizeof(nodeName), "(%04X)", (uint16_t)(node->num & 0xFFFF)); snprintf(nodeName, sizeof(nodeName), "(%04X)", (uint16_t)(node->num & 0xFFFF));
} }
return nodeName; return nodeName;
} }
+7 -25
View File
@@ -23,6 +23,7 @@
#include "power.h" #include "power.h"
#if !MESHTASTIC_EXCLUDE_I2C #if !MESHTASTIC_EXCLUDE_I2C
#include "detect/ScanI2CConsumer.h"
#include "detect/ScanI2CTwoWire.h" #include "detect/ScanI2CTwoWire.h"
#include <Wire.h> #include <Wire.h>
#endif #endif
@@ -718,46 +719,21 @@ void setup()
LOG_DEBUG("acc_info = %i", acc_info.type); LOG_DEBUG("acc_info = %i", acc_info.type);
#endif #endif
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::BME_680, meshtastic_TelemetrySensorType_BME680);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::BME_280, meshtastic_TelemetrySensorType_BME280);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::BMP_280, meshtastic_TelemetrySensorType_BMP280);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::BMP_3XX, meshtastic_TelemetrySensorType_BMP3XX);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::BMP_085, meshtastic_TelemetrySensorType_BMP085);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::INA260, meshtastic_TelemetrySensorType_INA260); scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::INA260, meshtastic_TelemetrySensorType_INA260);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::INA226, meshtastic_TelemetrySensorType_INA226); scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::INA226, meshtastic_TelemetrySensorType_INA226);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::INA219, meshtastic_TelemetrySensorType_INA219); scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::INA219, meshtastic_TelemetrySensorType_INA219);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::INA3221, meshtastic_TelemetrySensorType_INA3221); scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::INA3221, meshtastic_TelemetrySensorType_INA3221);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MAX17048, meshtastic_TelemetrySensorType_MAX17048); scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MAX17048, meshtastic_TelemetrySensorType_MAX17048);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MCP9808, meshtastic_TelemetrySensorType_MCP9808);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::SHT31, meshtastic_TelemetrySensorType_SHT31);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::SHTC3, meshtastic_TelemetrySensorType_SHTC3);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::LPS22HB, meshtastic_TelemetrySensorType_LPS22);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::QMC6310, meshtastic_TelemetrySensorType_QMC6310); scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::QMC6310, meshtastic_TelemetrySensorType_QMC6310);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::QMI8658, meshtastic_TelemetrySensorType_QMI8658); scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::QMI8658, meshtastic_TelemetrySensorType_QMI8658);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::QMC5883L, meshtastic_TelemetrySensorType_QMC5883L); scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::QMC5883L, meshtastic_TelemetrySensorType_QMC5883L);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::HMC5883L, meshtastic_TelemetrySensorType_QMC5883L); scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::HMC5883L, meshtastic_TelemetrySensorType_QMC5883L);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::PMSA0031, meshtastic_TelemetrySensorType_PMSA003I); scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::PMSA0031, meshtastic_TelemetrySensorType_PMSA003I);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::RCWL9620, meshtastic_TelemetrySensorType_RCWL9620);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::VEML7700, meshtastic_TelemetrySensorType_VEML7700);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::TSL2591, meshtastic_TelemetrySensorType_TSL25911FN);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::OPT3001, meshtastic_TelemetrySensorType_OPT3001);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MLX90632, meshtastic_TelemetrySensorType_MLX90632);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MLX90614, meshtastic_TelemetrySensorType_MLX90614); scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MLX90614, meshtastic_TelemetrySensorType_MLX90614);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::SHT4X, meshtastic_TelemetrySensorType_SHT4X);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::AHT10, meshtastic_TelemetrySensorType_AHT10);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::DFROBOT_LARK, meshtastic_TelemetrySensorType_DFROBOT_LARK);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::ICM20948, meshtastic_TelemetrySensorType_ICM20948); scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::ICM20948, meshtastic_TelemetrySensorType_ICM20948);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MAX30102, meshtastic_TelemetrySensorType_MAX30102); scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MAX30102, meshtastic_TelemetrySensorType_MAX30102);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::CGRADSENS, meshtastic_TelemetrySensorType_RADSENS);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::DFROBOT_RAIN, meshtastic_TelemetrySensorType_DFROBOT_RAIN);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::LTR390UV, meshtastic_TelemetrySensorType_LTR390UV);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::DPS310, meshtastic_TelemetrySensorType_DPS310);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::RAK12035, meshtastic_TelemetrySensorType_RAK12035);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::PCT2075, meshtastic_TelemetrySensorType_PCT2075);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::SCD4X, meshtastic_TelemetrySensorType_SCD4X); scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::SCD4X, meshtastic_TelemetrySensorType_SCD4X);
scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::TSL2561, meshtastic_TelemetrySensorType_TSL2561);
i2cScanner.reset();
#endif #endif
#ifdef HAS_SDCARD #ifdef HAS_SDCARD
@@ -964,6 +940,12 @@ void setup()
// Now that the mesh service is created, create any modules // Now that the mesh service is created, create any modules
setupModules(); setupModules();
#if !MESHTASTIC_EXCLUDE_I2C
// Inform modules about I2C devices
ScanI2CCompleted(i2cScanner.get());
i2cScanner.reset();
#endif
// warn the user about a low entropy key // warn the user about a low entropy key
if (nodeDB->keyIsLowEntropy && !nodeDB->hasWarned) { if (nodeDB->keyIsLowEntropy && !nodeDB->hasWarned) {
LOG_WARN(LOW_ENTROPY_WARNING); LOG_WARN(LOW_ENTROPY_WARNING);
+40 -18
View File
@@ -72,6 +72,7 @@ void PhoneAPI::handleStartConfig()
LOG_INFO("Start API client config"); LOG_INFO("Start API client config");
nodeInfoForPhone.num = 0; // Don't keep returning old nodeinfos nodeInfoForPhone.num = 0; // Don't keep returning old nodeinfos
nodeInfoQueue.clear();
resetReadIndex(); resetReadIndex();
} }
@@ -94,6 +95,7 @@ void PhoneAPI::close()
fromRadioScratch = {}; fromRadioScratch = {};
toRadioScratch = {}; toRadioScratch = {};
nodeInfoForPhone = {}; nodeInfoForPhone = {};
nodeInfoQueue.clear();
packetForPhone = NULL; packetForPhone = NULL;
filesManifest.clear(); filesManifest.clear();
fromRadioNum = 0; fromRadioNum = 0;
@@ -431,17 +433,25 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
break; break;
case STATE_SEND_OTHER_NODEINFOS: { case STATE_SEND_OTHER_NODEINFOS: {
LOG_DEBUG("Send known nodes");
if (nodeInfoForPhone.num == 0 && !nodeInfoQueue.empty()) {
// Serve the next cached node without re-reading from the DB iterator.
nodeInfoForPhone = nodeInfoQueue.front();
nodeInfoQueue.pop_front();
}
if (nodeInfoForPhone.num != 0) { if (nodeInfoForPhone.num != 0) {
// Just in case we stored a different user.id in the past, but should never happen going forward // Just in case we stored a different user.id in the past, but should never happen going forward
sprintf(nodeInfoForPhone.user.id, "!%08x", nodeInfoForPhone.num); sprintf(nodeInfoForPhone.user.id, "!%08x", nodeInfoForPhone.num);
LOG_INFO("nodeinfo: num=0x%x, lastseen=%u, id=%s, name=%s", nodeInfoForPhone.num, nodeInfoForPhone.last_heard, LOG_DEBUG("nodeinfo: num=0x%x, lastseen=%u, id=%s, name=%s", nodeInfoForPhone.num, nodeInfoForPhone.last_heard,
nodeInfoForPhone.user.id, nodeInfoForPhone.user.long_name); nodeInfoForPhone.user.id, nodeInfoForPhone.user.long_name);
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_node_info_tag; fromRadioScratch.which_payload_variant = meshtastic_FromRadio_node_info_tag;
fromRadioScratch.node_info = nodeInfoForPhone; fromRadioScratch.node_info = nodeInfoForPhone;
// Stay in current state until done sending nodeinfos nodeInfoForPhone = {};
nodeInfoForPhone.num = 0; // We just consumed a nodeinfo, will need a new one next time prefetchNodeInfos();
} else { } else {
LOG_DEBUG("Done sending nodeinfo"); LOG_DEBUG("Done sending nodeinfo");
nodeInfoQueue.clear();
state = STATE_SEND_FILEMANIFEST; state = STATE_SEND_FILEMANIFEST;
// Go ahead and send that ID right now // Go ahead and send that ID right now
return getFromRadio(buf); return getFromRadio(buf);
@@ -545,6 +555,30 @@ void PhoneAPI::releaseQueueStatusPhonePacket()
} }
} }
void PhoneAPI::prefetchNodeInfos()
{
bool added = false;
// Keep the queue topped up so BLE reads stay responsive even if DB fetches take a moment.
while (nodeInfoQueue.size() < kNodePrefetchDepth) {
auto nextNode = nodeDB->readNextMeshNode(readIndex);
if (!nextNode)
break;
auto info = TypeConversions::ConvertToNodeInfo(nextNode);
bool isUs = info.num == nodeDB->getNodeNum();
info.hops_away = isUs ? 0 : info.hops_away;
info.last_heard = isUs ? getValidTime(RTCQualityFromNet) : info.last_heard;
info.snr = isUs ? 0 : info.snr;
info.via_mqtt = isUs ? false : info.via_mqtt;
info.is_favorite = info.is_favorite || isUs;
nodeInfoQueue.push_back(info);
added = true;
}
if (added)
onNowHasData(0);
}
void PhoneAPI::releaseMqttClientProxyPhonePacket() void PhoneAPI::releaseMqttClientProxyPhonePacket()
{ {
if (mqttClientProxyMessageForPhone) { if (mqttClientProxyMessageForPhone) {
@@ -581,20 +615,8 @@ bool PhoneAPI::available()
return true; return true;
case STATE_SEND_OTHER_NODEINFOS: case STATE_SEND_OTHER_NODEINFOS:
if (nodeInfoForPhone.num == 0) { if (nodeInfoQueue.empty())
auto nextNode = nodeDB->readNextMeshNode(readIndex); prefetchNodeInfos();
if (nextNode) {
nodeInfoForPhone = TypeConversions::ConvertToNodeInfo(nextNode);
bool isUs = nodeInfoForPhone.num == nodeDB->getNodeNum();
nodeInfoForPhone.hops_away = isUs ? 0 : nodeInfoForPhone.hops_away;
nodeInfoForPhone.last_heard = isUs ? getValidTime(RTCQualityFromNet) : nodeInfoForPhone.last_heard;
nodeInfoForPhone.snr = isUs ? 0 : nodeInfoForPhone.snr;
nodeInfoForPhone.via_mqtt = isUs ? false : nodeInfoForPhone.via_mqtt;
nodeInfoForPhone.is_favorite = nodeInfoForPhone.is_favorite || isUs; // Our node is always a favorite
onNowHasData(0);
}
}
return true; // Always say we have something, because we might need to advance our state machine return true; // Always say we have something, because we might need to advance our state machine
case STATE_SEND_PACKETS: { case STATE_SEND_PACKETS: {
if (!queueStatusPacketForPhone) if (!queueStatusPacketForPhone)
+7
View File
@@ -3,6 +3,7 @@
#include "Observer.h" #include "Observer.h"
#include "mesh-pb-constants.h" #include "mesh-pb-constants.h"
#include "meshtastic/portnums.pb.h" #include "meshtastic/portnums.pb.h"
#include <deque>
#include <iterator> #include <iterator>
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
@@ -79,6 +80,10 @@ class PhoneAPI
/// We temporarily keep the nodeInfo here between the call to available and getFromRadio /// We temporarily keep the nodeInfo here between the call to available and getFromRadio
meshtastic_NodeInfo nodeInfoForPhone = meshtastic_NodeInfo_init_default; meshtastic_NodeInfo nodeInfoForPhone = meshtastic_NodeInfo_init_default;
// Prefetched node info entries ready for immediate transmission to the phone.
std::deque<meshtastic_NodeInfo> nodeInfoQueue;
// Tunable size of the node info cache so we can keep BLE reads non-blocking.
static constexpr size_t kNodePrefetchDepth = 4;
meshtastic_ToRadio toRadioScratch = { meshtastic_ToRadio toRadioScratch = {
0}; // this is a static scratch object, any data must be copied elsewhere before returning 0}; // this is a static scratch object, any data must be copied elsewhere before returning
@@ -158,6 +163,8 @@ class PhoneAPI
void releaseQueueStatusPhonePacket(); void releaseQueueStatusPhonePacket();
void prefetchNodeInfos();
void releaseMqttClientProxyPhonePacket(); void releaseMqttClientProxyPhonePacket();
void releaseClientNotification(); void releaseClientNotification();
+12 -11
View File
@@ -647,23 +647,24 @@ void RadioInterface::limitPower(int8_t loraMaxPower)
} }
#ifndef NUM_PA_POINTS #ifndef NUM_PA_POINTS
if (TX_GAIN_LORA > 0) { if (TX_GAIN_LORA > 0 && !devicestate.owner.is_licensed) {
LOG_INFO("Requested Tx power: %d dBm; Device LoRa Tx gain: %d dB", power, TX_GAIN_LORA); LOG_INFO("Requested Tx power: %d dBm; Device LoRa Tx gain: %d dB", power, TX_GAIN_LORA);
power -= TX_GAIN_LORA; power -= TX_GAIN_LORA;
} }
#else #else
// we have an array of PA gain values. Find the highest power setting that works. if (!devicestate.owner.is_licensed) {
const uint16_t tx_gain[NUM_PA_POINTS] = {TX_GAIN_LORA}; // we have an array of PA gain values. Find the highest power setting that works.
for (int radio_dbm = 0; radio_dbm < NUM_PA_POINTS; radio_dbm++) { const uint16_t tx_gain[NUM_PA_POINTS] = {TX_GAIN_LORA};
if (((radio_dbm + tx_gain[radio_dbm]) > power) || for (int radio_dbm = 0; radio_dbm < NUM_PA_POINTS; radio_dbm++) {
((radio_dbm == (NUM_PA_POINTS - 1)) && ((radio_dbm + tx_gain[radio_dbm]) <= power))) { if (((radio_dbm + tx_gain[radio_dbm]) > power) ||
// we've exceeded the power limit, or hit the max we can do ((radio_dbm == (NUM_PA_POINTS - 1)) && ((radio_dbm + tx_gain[radio_dbm]) <= power))) {
LOG_INFO("Requested Tx power: %d dBm; Device LoRa Tx gain: %d dB", power, tx_gain[radio_dbm]); // we've exceeded the power limit, or hit the max we can do
power -= tx_gain[radio_dbm]; LOG_INFO("Requested Tx power: %d dBm; Device LoRa Tx gain: %d dB", power, tx_gain[radio_dbm]);
break; power -= tx_gain[radio_dbm];
break;
}
} }
} }
#endif #endif
if (power > loraMaxPower) // Clamp power to maximum defined level if (power > loraMaxPower) // Clamp power to maximum defined level
power = loraMaxPower; power = loraMaxPower;
+2
View File
@@ -95,10 +95,12 @@ static void onNetworkConnected()
#ifdef ARCH_ESP32 #ifdef ARCH_ESP32
MDNS.addServiceTxt("meshtastic", "tcp", "shortname", String(owner.short_name)); MDNS.addServiceTxt("meshtastic", "tcp", "shortname", String(owner.short_name));
MDNS.addServiceTxt("meshtastic", "tcp", "id", String(nodeDB->getNodeId().c_str())); MDNS.addServiceTxt("meshtastic", "tcp", "id", String(nodeDB->getNodeId().c_str()));
MDNS.addServiceTxt("meshtastic", "tcp", "pio_env", optstr(APP_ENV));
// ESP32 prints obtained IP address in WiFiEvent // ESP32 prints obtained IP address in WiFiEvent
#elif defined(ARCH_RP2040) #elif defined(ARCH_RP2040)
MDNS.addServiceTxt("meshtastic", "shortname", owner.short_name); MDNS.addServiceTxt("meshtastic", "shortname", owner.short_name);
MDNS.addServiceTxt("meshtastic", "id", nodeDB->getNodeId().c_str()); MDNS.addServiceTxt("meshtastic", "id", nodeDB->getNodeId().c_str());
MDNS.addServiceTxt("meshtastic", "pio_env", optstr(APP_ENV));
LOG_INFO("Obtained IP address: %s", WiFi.localIP().toString().c_str()); LOG_INFO("Obtained IP address: %s", WiFi.localIP().toString().c_str());
#endif #endif
} }
+151 -383
View File
@@ -35,175 +35,103 @@ extern void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y, const c
} }
#if __has_include(<Adafruit_AHTX0.h>) #if __has_include(<Adafruit_AHTX0.h>)
#include "Sensor/AHT10.h" #include "Sensor/AHT10.h"
AHT10Sensor aht10Sensor;
#else
NullSensor aht10Sensor;
#endif #endif
#if __has_include(<Adafruit_BME280.h>) #if __has_include(<Adafruit_BME280.h>)
#include "Sensor/BME280Sensor.h" #include "Sensor/BME280Sensor.h"
BME280Sensor bme280Sensor;
#else
NullSensor bmp280Sensor;
#endif #endif
#if __has_include(<Adafruit_BMP085.h>) #if __has_include(<Adafruit_BMP085.h>)
#include "Sensor/BMP085Sensor.h" #include "Sensor/BMP085Sensor.h"
BMP085Sensor bmp085Sensor;
#else
NullSensor bmp085Sensor;
#endif #endif
#if __has_include(<Adafruit_BMP280.h>) #if __has_include(<Adafruit_BMP280.h>)
#include "Sensor/BMP280Sensor.h" #include "Sensor/BMP280Sensor.h"
BMP280Sensor bmp280Sensor;
#else
NullSensor bme280Sensor;
#endif #endif
#if __has_include(<Adafruit_LTR390.h>) #if __has_include(<Adafruit_LTR390.h>)
#include "Sensor/LTR390UVSensor.h" #include "Sensor/LTR390UVSensor.h"
LTR390UVSensor ltr390uvSensor;
#else
NullSensor ltr390uvSensor;
#endif #endif
#if __has_include(<bsec2.h>) #if __has_include(<bsec2.h>)
#include "Sensor/BME680Sensor.h" #include "Sensor/BME680Sensor.h"
BME680Sensor bme680Sensor;
#else
NullSensor bme680Sensor;
#endif #endif
#if __has_include(<Adafruit_DPS310.h>) #if __has_include(<Adafruit_DPS310.h>)
#include "Sensor/DPS310Sensor.h" #include "Sensor/DPS310Sensor.h"
DPS310Sensor dps310Sensor;
#else
NullSensor dps310Sensor;
#endif #endif
#if __has_include(<Adafruit_MCP9808.h>) #if __has_include(<Adafruit_MCP9808.h>)
#include "Sensor/MCP9808Sensor.h" #include "Sensor/MCP9808Sensor.h"
MCP9808Sensor mcp9808Sensor;
#else
NullSensor mcp9808Sensor;
#endif #endif
#if __has_include(<Adafruit_SHT31.h>) #if __has_include(<Adafruit_SHT31.h>)
#include "Sensor/SHT31Sensor.h" #include "Sensor/SHT31Sensor.h"
SHT31Sensor sht31Sensor;
#else
NullSensor sht31Sensor;
#endif #endif
#if __has_include(<Adafruit_LPS2X.h>) #if __has_include(<Adafruit_LPS2X.h>)
#include "Sensor/LPS22HBSensor.h" #include "Sensor/LPS22HBSensor.h"
LPS22HBSensor lps22hbSensor;
#else
NullSensor lps22hbSensor;
#endif #endif
#if __has_include(<Adafruit_SHTC3.h>) #if __has_include(<Adafruit_SHTC3.h>)
#include "Sensor/SHTC3Sensor.h" #include "Sensor/SHTC3Sensor.h"
SHTC3Sensor shtc3Sensor;
#else
NullSensor shtc3Sensor;
#endif #endif
#if __has_include("RAK12035_SoilMoisture.h") && defined(RAK_4631) && RAK_4631 == 1 #if __has_include("RAK12035_SoilMoisture.h") && defined(RAK_4631) && RAK_4631 == 1
#include "Sensor/RAK12035Sensor.h" #include "Sensor/RAK12035Sensor.h"
RAK12035Sensor rak12035Sensor;
#else
NullSensor rak12035Sensor;
#endif #endif
#if __has_include(<Adafruit_VEML7700.h>) #if __has_include(<Adafruit_VEML7700.h>)
#include "Sensor/VEML7700Sensor.h" #include "Sensor/VEML7700Sensor.h"
VEML7700Sensor veml7700Sensor;
#else
NullSensor veml7700Sensor;
#endif #endif
#if __has_include(<Adafruit_TSL2591.h>) #if __has_include(<Adafruit_TSL2591.h>)
#include "Sensor/TSL2591Sensor.h" #include "Sensor/TSL2591Sensor.h"
TSL2591Sensor tsl2591Sensor;
#else
NullSensor tsl2591Sensor;
#endif #endif
#if __has_include(<ClosedCube_OPT3001.h>) #if __has_include(<ClosedCube_OPT3001.h>)
#include "Sensor/OPT3001Sensor.h" #include "Sensor/OPT3001Sensor.h"
OPT3001Sensor opt3001Sensor;
#else
NullSensor opt3001Sensor;
#endif #endif
#if __has_include(<Adafruit_SHT4x.h>) #if __has_include(<Adafruit_SHT4x.h>)
#include "Sensor/SHT4XSensor.h" #include "Sensor/SHT4XSensor.h"
SHT4XSensor sht4xSensor;
#else
NullSensor sht4xSensor;
#endif #endif
#if __has_include(<SparkFun_MLX90632_Arduino_Library.h>) #if __has_include(<SparkFun_MLX90632_Arduino_Library.h>)
#include "Sensor/MLX90632Sensor.h" #include "Sensor/MLX90632Sensor.h"
MLX90632Sensor mlx90632Sensor;
#else
NullSensor mlx90632Sensor;
#endif #endif
#if __has_include(<DFRobot_LarkWeatherStation.h>) #if __has_include(<DFRobot_LarkWeatherStation.h>)
#include "Sensor/DFRobotLarkSensor.h" #include "Sensor/DFRobotLarkSensor.h"
DFRobotLarkSensor dfRobotLarkSensor;
#else
NullSensor dfRobotLarkSensor;
#endif #endif
#if __has_include(<DFRobot_RainfallSensor.h>) #if __has_include(<DFRobot_RainfallSensor.h>)
#include "Sensor/DFRobotGravitySensor.h" #include "Sensor/DFRobotGravitySensor.h"
DFRobotGravitySensor dfRobotGravitySensor;
#else
NullSensor dfRobotGravitySensor;
#endif #endif
#if __has_include(<SparkFun_Qwiic_Scale_NAU7802_Arduino_Library.h>) #if __has_include(<SparkFun_Qwiic_Scale_NAU7802_Arduino_Library.h>)
#include "Sensor/NAU7802Sensor.h" #include "Sensor/NAU7802Sensor.h"
NAU7802Sensor nau7802Sensor;
#else
NullSensor nau7802Sensor;
#endif #endif
#if __has_include(<Adafruit_BMP3XX.h>) #if __has_include(<Adafruit_BMP3XX.h>)
#include "Sensor/BMP3XXSensor.h" #include "Sensor/BMP3XXSensor.h"
BMP3XXSensor bmp3xxSensor;
#else
NullSensor bmp3xxSensor;
#endif #endif
#if __has_include(<Adafruit_PCT2075.h>) #if __has_include(<Adafruit_PCT2075.h>)
#include "Sensor/PCT2075Sensor.h" #include "Sensor/PCT2075Sensor.h"
PCT2075Sensor pct2075Sensor;
#else
NullSensor pct2075Sensor;
#endif #endif
RCWL9620Sensor rcwl9620Sensor;
CGRadSensSensor cgRadSens;
#endif #endif
#ifdef T1000X_SENSOR_EN #ifdef T1000X_SENSOR_EN
#include "Sensor/T1000xSensor.h" #include "Sensor/T1000xSensor.h"
T1000xSensor t1000xSensor;
#endif #endif
#ifdef SENSECAP_INDICATOR #ifdef SENSECAP_INDICATOR
#include "Sensor/IndicatorSensor.h" #include "Sensor/IndicatorSensor.h"
IndicatorSensor indicatorSensor;
#endif #endif
#if __has_include(<Adafruit_TSL2561_U.h>) #if __has_include(<Adafruit_TSL2561_U.h>)
#include "Sensor/TSL2561Sensor.h" #include "Sensor/TSL2561Sensor.h"
TSL2561Sensor tsl2561Sensor;
#else
NullSensor tsl2561Sensor;
#endif #endif
#define FAILED_STATE_SENSOR_READ_MULTIPLIER 10 #define FAILED_STATE_SENSOR_READ_MULTIPLIER 10
@@ -212,6 +140,132 @@ NullSensor tsl2561Sensor;
#include "graphics/ScreenFonts.h" #include "graphics/ScreenFonts.h"
#include <Throttle.h> #include <Throttle.h>
#include <forward_list>
static std::forward_list<TelemetrySensor *> sensors;
template <typename T> void addSensor(ScanI2C *i2cScanner, ScanI2C::DeviceType type)
{
ScanI2C::FoundDevice dev = i2cScanner->find(type);
if (dev.type != ScanI2C::DeviceType::NONE || type == ScanI2C::DeviceType::NONE) {
TelemetrySensor *sensor = new T();
#if WIRE_INTERFACES_COUNT > 1
TwoWire *bus = ScanI2CTwoWire::fetchI2CBus(dev.address);
if (dev.address.port != ScanI2C::I2CPort::WIRE1 && sensor->onlyWire1()) {
// This sensor only works on Wire (Wire1 is not supported)
delete sensor;
return;
}
#else
TwoWire *bus = &Wire;
#endif
if (sensor->initDevice(bus, &dev)) {
sensors.push_front(sensor);
return;
}
// destroy sensor
delete sensor;
}
}
void EnvironmentTelemetryModule::i2cScanFinished(ScanI2C *i2cScanner)
{
if (!moduleConfig.telemetry.environment_measurement_enabled && !ENVIRONMENTAL_TELEMETRY_MODULE_ENABLE) {
return;
}
LOG_INFO("Environment Telemetry adding I2C devices...");
// order by priority of metrics/values (low top, high bottom)
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
#ifdef T1000X_SENSOR_EN
// Not a real I2C device
addSensor<T1000xSensor>(i2cScanner, ScanI2C::DeviceType::NONE);
#else
#ifdef SENSECAP_INDICATOR
// Not a real I2C device, uses UART
addSensor<IndicatorSensor>(i2cScanner, ScanI2C::DeviceType::NONE);
#endif
addSensor<RCWL9620Sensor>(i2cScanner, ScanI2C::DeviceType::RCWL9620);
addSensor<CGRadSensSensor>(i2cScanner, ScanI2C::DeviceType::CGRADSENS);
#endif
#endif
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR_EXTERNAL
#if __has_include(<DFRobot_LarkWeatherStation.h>)
addSensor<DFRobotLarkSensor>(i2cScanner, ScanI2C::DeviceType::DFROBOT_LARK);
#endif
#if __has_include(<DFRobot_RainfallSensor.h>)
addSensor<DFRobotGravitySensor>(i2cScanner, ScanI2C::DeviceType::DFROBOT_RAIN);
#endif
#if __has_include(<Adafruit_AHTX0.h>)
addSensor<AHT10Sensor>(i2cScanner, ScanI2C::DeviceType::AHT10);
#endif
#if __has_include(<Adafruit_BMP085.h>)
addSensor<BMP085Sensor>(i2cScanner, ScanI2C::DeviceType::BMP_085);
#endif
#if __has_include(<Adafruit_BME280.h>)
addSensor<BME280Sensor>(i2cScanner, ScanI2C::DeviceType::BME_280);
#endif
#if __has_include(<Adafruit_LTR390.h>)
addSensor<LTR390UVSensor>(i2cScanner, ScanI2C::DeviceType::LTR390UV);
#endif
#if __has_include(<bsec2.h>)
addSensor<BME680Sensor>(i2cScanner, ScanI2C::DeviceType::BME_680);
#endif
#if __has_include(<Adafruit_BMP280.h>)
addSensor<BMP280Sensor>(i2cScanner, ScanI2C::DeviceType::BMP_280);
#endif
#if __has_include(<Adafruit_DPS310.h>)
addSensor<DPS310Sensor>(i2cScanner, ScanI2C::DeviceType::DPS310);
#endif
#if __has_include(<Adafruit_MCP9808.h>)
addSensor<MCP9808Sensor>(i2cScanner, ScanI2C::DeviceType::MCP9808);
#endif
#if __has_include(<Adafruit_SHT31.h>)
addSensor<SHT31Sensor>(i2cScanner, ScanI2C::DeviceType::SHT31);
#endif
#if __has_include(<Adafruit_LPS2X.h>)
addSensor<LPS22HBSensor>(i2cScanner, ScanI2C::DeviceType::LPS22HB);
#endif
#if __has_include(<Adafruit_SHTC3.h>)
addSensor<SHTC3Sensor>(i2cScanner, ScanI2C::DeviceType::SHTC3);
#endif
#if __has_include("RAK12035_SoilMoisture.h") && defined(RAK_4631) && RAK_4631 == 1
addSensor<RAK12035Sensor>(i2cScanner, ScanI2C::DeviceType::RAK12035);
#endif
#if __has_include(<Adafruit_VEML7700.h>)
addSensor<VEML7700Sensor>(i2cScanner, ScanI2C::DeviceType::VEML7700);
#endif
#if __has_include(<Adafruit_TSL2591.h>)
addSensor<TSL2591Sensor>(i2cScanner, ScanI2C::DeviceType::TSL2591);
#endif
#if __has_include(<ClosedCube_OPT3001.h>)
addSensor<OPT3001Sensor>(i2cScanner, ScanI2C::DeviceType::OPT3001);
#endif
#if __has_include(<Adafruit_SHT4x.h>)
addSensor<SHT4XSensor>(i2cScanner, ScanI2C::DeviceType::SHT4X);
#endif
#if __has_include(<SparkFun_MLX90632_Arduino_Library.h>)
addSensor<MLX90632Sensor>(i2cScanner, ScanI2C::DeviceType::MLX90632);
#endif
#if __has_include(<Adafruit_BMP3XX.h>)
addSensor<BMP3XXSensor>(i2cScanner, ScanI2C::DeviceType::BMP_3XX);
#endif
#if __has_include(<Adafruit_PCT2075.h>)
addSensor<PCT2075Sensor>(i2cScanner, ScanI2C::DeviceType::PCT2075);
#endif
#if __has_include(<Adafruit_TSL2561_U.h>)
addSensor<TSL2561Sensor>(i2cScanner, ScanI2C::DeviceType::TSL2561);
#endif
#if __has_include(<SparkFun_Qwiic_Scale_NAU7802_Arduino_Library.h>)
addSensor<NAU7802Sensor>(i2cScanner, ScanI2C::DeviceType::NAU7802);
#endif
#endif
}
int32_t EnvironmentTelemetryModule::runOnce() int32_t EnvironmentTelemetryModule::runOnce()
{ {
if (sleepOnNextExecution == true) { if (sleepOnNextExecution == true) {
@@ -244,81 +298,27 @@ int32_t EnvironmentTelemetryModule::runOnce()
if (moduleConfig.telemetry.environment_measurement_enabled || ENVIRONMENTAL_TELEMETRY_MODULE_ENABLE) { if (moduleConfig.telemetry.environment_measurement_enabled || ENVIRONMENTAL_TELEMETRY_MODULE_ENABLE) {
LOG_INFO("Environment Telemetry: init"); LOG_INFO("Environment Telemetry: init");
#ifdef SENSECAP_INDICATOR
result = indicatorSensor.runOnce(); // check if we have at least one sensor
#endif if (!sensors.empty()) {
result = DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
#ifdef T1000X_SENSOR_EN #ifdef T1000X_SENSOR_EN
result = t1000xSensor.runOnce();
#elif !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR_EXTERNAL #elif !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR_EXTERNAL
if (dfRobotLarkSensor.hasSensor())
result = dfRobotLarkSensor.runOnce();
if (dfRobotGravitySensor.hasSensor())
result = dfRobotGravitySensor.runOnce();
if (bmp085Sensor.hasSensor())
result = bmp085Sensor.runOnce();
#if __has_include(<Adafruit_BME280.h>)
if (bmp280Sensor.hasSensor())
result = bmp280Sensor.runOnce();
#endif
if (bme280Sensor.hasSensor())
result = bme280Sensor.runOnce();
if (ltr390uvSensor.hasSensor())
result = ltr390uvSensor.runOnce();
if (bmp3xxSensor.hasSensor())
result = bmp3xxSensor.runOnce();
if (bme680Sensor.hasSensor())
result = bme680Sensor.runOnce();
if (dps310Sensor.hasSensor())
result = dps310Sensor.runOnce();
if (mcp9808Sensor.hasSensor())
result = mcp9808Sensor.runOnce();
if (shtc3Sensor.hasSensor())
result = shtc3Sensor.runOnce();
if (lps22hbSensor.hasSensor())
result = lps22hbSensor.runOnce();
if (sht31Sensor.hasSensor())
result = sht31Sensor.runOnce();
if (sht4xSensor.hasSensor())
result = sht4xSensor.runOnce();
if (ina219Sensor.hasSensor()) if (ina219Sensor.hasSensor())
result = ina219Sensor.runOnce(); result = ina219Sensor.runOnce();
if (ina260Sensor.hasSensor()) if (ina260Sensor.hasSensor())
result = ina260Sensor.runOnce(); result = ina260Sensor.runOnce();
if (ina3221Sensor.hasSensor()) if (ina3221Sensor.hasSensor())
result = ina3221Sensor.runOnce(); result = ina3221Sensor.runOnce();
if (veml7700Sensor.hasSensor())
result = veml7700Sensor.runOnce();
if (tsl2591Sensor.hasSensor())
result = tsl2591Sensor.runOnce();
if (opt3001Sensor.hasSensor())
result = opt3001Sensor.runOnce();
if (rcwl9620Sensor.hasSensor())
result = rcwl9620Sensor.runOnce();
if (aht10Sensor.hasSensor())
result = aht10Sensor.runOnce();
if (mlx90632Sensor.hasSensor())
result = mlx90632Sensor.runOnce();
if (nau7802Sensor.hasSensor())
result = nau7802Sensor.runOnce();
if (max17048Sensor.hasSensor()) if (max17048Sensor.hasSensor())
result = max17048Sensor.runOnce(); result = max17048Sensor.runOnce();
if (cgRadSens.hasSensor())
result = cgRadSens.runOnce();
if (tsl2561Sensor.hasSensor())
result = tsl2561Sensor.runOnce();
if (pct2075Sensor.hasSensor())
result = pct2075Sensor.runOnce();
// this only works on the wismesh hub with the solar option. This is not an I2C sensor, so we don't need the // this only works on the wismesh hub with the solar option. This is not an I2C sensor, so we don't need the
// sensormap here. // sensormap here.
#ifdef HAS_RAKPROT #ifdef HAS_RAKPROT
result = rak9154Sensor.runOnce(); result = rak9154Sensor.runOnce();
#endif #endif
#if __has_include("RAK12035_SoilMoisture.h") && defined(RAK_4631) && RAK_4631 == 1
if (rak12035Sensor.hasSensor()) {
result = rak12035Sensor.runOnce();
}
#endif
#endif #endif
} }
// it's possible to have this module enabled, only for displaying values on the screen. // it's possible to have this module enabled, only for displaying values on the screen.
@@ -328,11 +328,13 @@ int32_t EnvironmentTelemetryModule::runOnce()
// if we somehow got to a second run of this module with measurement disabled, then just wait forever // if we somehow got to a second run of this module with measurement disabled, then just wait forever
if (!moduleConfig.telemetry.environment_measurement_enabled && !ENVIRONMENTAL_TELEMETRY_MODULE_ENABLE) { if (!moduleConfig.telemetry.environment_measurement_enabled && !ENVIRONMENTAL_TELEMETRY_MODULE_ENABLE) {
return disable(); return disable();
} else { }
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR_EXTERNAL
if (bme680Sensor.hasSensor()) for (TelemetrySensor *sensor : sensors) {
result = bme680Sensor.runTrigger(); uint32_t delay = sensor->runOnce();
#endif if (delay < result) {
result = delay;
}
} }
if (((lastSentToMesh == 0) || if (((lastSentToMesh == 0) ||
@@ -550,72 +552,12 @@ bool EnvironmentTelemetryModule::getEnvironmentTelemetry(meshtastic_Telemetry *m
m->which_variant = meshtastic_Telemetry_environment_metrics_tag; m->which_variant = meshtastic_Telemetry_environment_metrics_tag;
m->variant.environment_metrics = meshtastic_EnvironmentMetrics_init_zero; m->variant.environment_metrics = meshtastic_EnvironmentMetrics_init_zero;
#ifdef SENSECAP_INDICATOR for (TelemetrySensor *sensor : sensors) {
valid = valid && indicatorSensor.getMetrics(m); valid = valid && sensor->getMetrics(m);
hasSensor = true;
#endif
#ifdef T1000X_SENSOR_EN // add by WayenWeng
valid = valid && t1000xSensor.getMetrics(m);
hasSensor = true;
#else
if (dfRobotLarkSensor.hasSensor()) {
valid = valid && dfRobotLarkSensor.getMetrics(m);
hasSensor = true;
}
if (dfRobotGravitySensor.hasSensor()) {
valid = valid && dfRobotGravitySensor.getMetrics(m);
hasSensor = true;
}
if (sht31Sensor.hasSensor()) {
valid = valid && sht31Sensor.getMetrics(m);
hasSensor = true;
}
if (sht4xSensor.hasSensor()) {
valid = valid && sht4xSensor.getMetrics(m);
hasSensor = true;
}
if (lps22hbSensor.hasSensor()) {
valid = valid && lps22hbSensor.getMetrics(m);
hasSensor = true;
}
if (shtc3Sensor.hasSensor()) {
valid = valid && shtc3Sensor.getMetrics(m);
hasSensor = true;
}
if (bmp085Sensor.hasSensor()) {
valid = valid && bmp085Sensor.getMetrics(m);
hasSensor = true;
}
#if __has_include(<Adafruit_BME280.h>)
if (bmp280Sensor.hasSensor()) {
valid = valid && bmp280Sensor.getMetrics(m);
hasSensor = true;
}
#endif
if (bme280Sensor.hasSensor()) {
valid = valid && bme280Sensor.getMetrics(m);
hasSensor = true;
}
if (ltr390uvSensor.hasSensor()) {
valid = valid && ltr390uvSensor.getMetrics(m);
hasSensor = true;
}
if (bmp3xxSensor.hasSensor()) {
valid = valid && bmp3xxSensor.getMetrics(m);
hasSensor = true;
}
if (bme680Sensor.hasSensor()) {
valid = valid && bme680Sensor.getMetrics(m);
hasSensor = true;
}
if (dps310Sensor.hasSensor()) {
valid = valid && dps310Sensor.getMetrics(m);
hasSensor = true;
}
if (mcp9808Sensor.hasSensor()) {
valid = valid && mcp9808Sensor.getMetrics(m);
hasSensor = true; hasSensor = true;
} }
#ifndef T1000X_SENSOR_EN
if (ina219Sensor.hasSensor()) { if (ina219Sensor.hasSensor()) {
valid = valid && ina219Sensor.getMetrics(m); valid = valid && ina219Sensor.getMetrics(m);
hasSensor = true; hasSensor = true;
@@ -628,78 +570,14 @@ bool EnvironmentTelemetryModule::getEnvironmentTelemetry(meshtastic_Telemetry *m
valid = valid && ina3221Sensor.getMetrics(m); valid = valid && ina3221Sensor.getMetrics(m);
hasSensor = true; hasSensor = true;
} }
if (veml7700Sensor.hasSensor()) {
valid = valid && veml7700Sensor.getMetrics(m);
hasSensor = true;
}
if (tsl2591Sensor.hasSensor()) {
valid = valid && tsl2591Sensor.getMetrics(m);
hasSensor = true;
}
if (opt3001Sensor.hasSensor()) {
valid = valid && opt3001Sensor.getMetrics(m);
hasSensor = true;
}
if (mlx90632Sensor.hasSensor()) {
valid = valid && mlx90632Sensor.getMetrics(m);
hasSensor = true;
}
if (rcwl9620Sensor.hasSensor()) {
valid = valid && rcwl9620Sensor.getMetrics(m);
hasSensor = true;
}
if (nau7802Sensor.hasSensor()) {
valid = valid && nau7802Sensor.getMetrics(m);
hasSensor = true;
}
if (tsl2561Sensor.hasSensor()) {
valid = valid && tsl2561Sensor.getMetrics(m);
hasSensor = true;
}
if (aht10Sensor.hasSensor()) {
if (!bmp280Sensor.hasSensor() && !bmp3xxSensor.hasSensor()) {
valid = valid && aht10Sensor.getMetrics(m);
hasSensor = true;
} else if (bmp280Sensor.hasSensor()) {
// prefer bmp280 temp if both sensors are present, fetch only humidity
meshtastic_Telemetry m_ahtx = meshtastic_Telemetry_init_zero;
LOG_INFO("AHTX0+BMP280 module detected: using temp from BMP280 and humy from AHTX0");
aht10Sensor.getMetrics(&m_ahtx);
m->variant.environment_metrics.relative_humidity = m_ahtx.variant.environment_metrics.relative_humidity;
m->variant.environment_metrics.has_relative_humidity = m_ahtx.variant.environment_metrics.has_relative_humidity;
} else {
// prefer bmp3xx temp if both sensors are present, fetch only humidity
meshtastic_Telemetry m_ahtx = meshtastic_Telemetry_init_zero;
LOG_INFO("AHTX0+BMP3XX module detected: using temp from BMP3XX and humy from AHTX0");
aht10Sensor.getMetrics(&m_ahtx);
m->variant.environment_metrics.relative_humidity = m_ahtx.variant.environment_metrics.relative_humidity;
m->variant.environment_metrics.has_relative_humidity = m_ahtx.variant.environment_metrics.has_relative_humidity;
}
}
if (max17048Sensor.hasSensor()) { if (max17048Sensor.hasSensor()) {
valid = valid && max17048Sensor.getMetrics(m); valid = valid && max17048Sensor.getMetrics(m);
hasSensor = true; hasSensor = true;
} }
if (cgRadSens.hasSensor()) { #endif
valid = valid && cgRadSens.getMetrics(m);
hasSensor = true;
}
if (pct2075Sensor.hasSensor()) {
valid = valid && pct2075Sensor.getMetrics(m);
hasSensor = true;
}
#ifdef HAS_RAKPROT #ifdef HAS_RAKPROT
valid = valid && rak9154Sensor.getMetrics(m); valid = valid && rak9154Sensor.getMetrics(m);
hasSensor = true; hasSensor = true;
#endif
#if __has_include("RAK12035_SoilMoisture.h") && defined(RAK_4631) && \
RAK_4631 == \
1 // Not really needed, but may as well just skip at a lower level it if no library or not a RAK_4631
if (rak12035Sensor.hasSensor()) {
valid = valid && rak12035Sensor.getMetrics(m);
hasSensor = true;
}
#endif
#endif #endif
return valid && hasSensor; return valid && hasSensor;
} }
@@ -737,11 +615,8 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly)
meshtastic_Telemetry m = meshtastic_Telemetry_init_zero; meshtastic_Telemetry m = meshtastic_Telemetry_init_zero;
m.which_variant = meshtastic_Telemetry_environment_metrics_tag; m.which_variant = meshtastic_Telemetry_environment_metrics_tag;
m.time = getTime(); m.time = getTime();
#ifdef T1000X_SENSOR_EN
if (t1000xSensor.getMetrics(&m)) {
#else
if (getEnvironmentTelemetry(&m)) { if (getEnvironmentTelemetry(&m)) {
#endif
LOG_INFO("Send: barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, temperature=%f", LOG_INFO("Send: barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, temperature=%f",
m.variant.environment_metrics.barometric_pressure, m.variant.environment_metrics.current, m.variant.environment_metrics.barometric_pressure, m.variant.environment_metrics.current,
m.variant.environment_metrics.gas_resistance, m.variant.environment_metrics.relative_humidity, m.variant.environment_metrics.gas_resistance, m.variant.environment_metrics.relative_humidity,
@@ -803,71 +678,13 @@ AdminMessageHandleResult EnvironmentTelemetryModule::handleAdminMessageForModule
{ {
AdminMessageHandleResult result = AdminMessageHandleResult::NOT_HANDLED; AdminMessageHandleResult result = AdminMessageHandleResult::NOT_HANDLED;
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR_EXTERNAL #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR_EXTERNAL
if (dfRobotLarkSensor.hasSensor()) {
result = dfRobotLarkSensor.handleAdminMessage(mp, request, response); for (TelemetrySensor *sensor : sensors) {
if (result != AdminMessageHandleResult::NOT_HANDLED) result = sensor->handleAdminMessage(mp, request, response);
return result;
}
if (dfRobotGravitySensor.hasSensor()) {
result = dfRobotGravitySensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED)
return result;
}
if (sht31Sensor.hasSensor()) {
result = sht31Sensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED)
return result;
}
if (lps22hbSensor.hasSensor()) {
result = lps22hbSensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED)
return result;
}
if (shtc3Sensor.hasSensor()) {
result = shtc3Sensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED)
return result;
}
if (bmp085Sensor.hasSensor()) {
result = bmp085Sensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED)
return result;
}
if (bmp280Sensor.hasSensor()) {
result = bmp280Sensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED)
return result;
}
if (bme280Sensor.hasSensor()) {
result = bme280Sensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED)
return result;
}
if (ltr390uvSensor.hasSensor()) {
result = ltr390uvSensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED)
return result;
}
if (bmp3xxSensor.hasSensor()) {
result = bmp3xxSensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED)
return result;
}
if (bme680Sensor.hasSensor()) {
result = bme680Sensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED)
return result;
}
if (dps310Sensor.hasSensor()) {
result = dps310Sensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED)
return result;
}
if (mcp9808Sensor.hasSensor()) {
result = mcp9808Sensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED) if (result != AdminMessageHandleResult::NOT_HANDLED)
return result; return result;
} }
if (ina219Sensor.hasSensor()) { if (ina219Sensor.hasSensor()) {
result = ina219Sensor.handleAdminMessage(mp, request, response); result = ina219Sensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED) if (result != AdminMessageHandleResult::NOT_HANDLED)
@@ -883,60 +700,11 @@ AdminMessageHandleResult EnvironmentTelemetryModule::handleAdminMessageForModule
if (result != AdminMessageHandleResult::NOT_HANDLED) if (result != AdminMessageHandleResult::NOT_HANDLED)
return result; return result;
} }
if (veml7700Sensor.hasSensor()) {
result = veml7700Sensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED)
return result;
}
if (tsl2591Sensor.hasSensor()) {
result = tsl2591Sensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED)
return result;
}
if (opt3001Sensor.hasSensor()) {
result = opt3001Sensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED)
return result;
}
if (mlx90632Sensor.hasSensor()) {
result = mlx90632Sensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED)
return result;
}
if (rcwl9620Sensor.hasSensor()) {
result = rcwl9620Sensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED)
return result;
}
if (nau7802Sensor.hasSensor()) {
result = nau7802Sensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED)
return result;
}
if (aht10Sensor.hasSensor()) {
result = aht10Sensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED)
return result;
}
if (max17048Sensor.hasSensor()) { if (max17048Sensor.hasSensor()) {
result = max17048Sensor.handleAdminMessage(mp, request, response); result = max17048Sensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED) if (result != AdminMessageHandleResult::NOT_HANDLED)
return result; return result;
} }
if (cgRadSens.hasSensor()) {
result = cgRadSens.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED)
return result;
}
#if __has_include("RAK12035_SoilMoisture.h") && defined(RAK_4631) && \
RAK_4631 == \
1 // Not really needed, but may as well just skip it at a lower level if no library or not a RAK_4631
if (rak12035Sensor.hasSensor()) {
result = rak12035Sensor.handleAdminMessage(mp, request, response);
if (result != AdminMessageHandleResult::NOT_HANDLED)
return result;
}
#endif
#endif #endif
return result; return result;
} }
+7 -2
View File
@@ -11,10 +11,13 @@
#include "../mesh/generated/meshtastic/telemetry.pb.h" #include "../mesh/generated/meshtastic/telemetry.pb.h"
#include "NodeDB.h" #include "NodeDB.h"
#include "ProtobufModule.h" #include "ProtobufModule.h"
#include "detect/ScanI2CConsumer.h"
#include <OLEDDisplay.h> #include <OLEDDisplay.h>
#include <OLEDDisplayUi.h> #include <OLEDDisplayUi.h>
class EnvironmentTelemetryModule : private concurrency::OSThread, public ProtobufModule<meshtastic_Telemetry> class EnvironmentTelemetryModule : private concurrency::OSThread,
public ScanI2CConsumer,
public ProtobufModule<meshtastic_Telemetry>
{ {
CallbackObserver<EnvironmentTelemetryModule, const meshtastic::Status *> nodeStatusObserver = CallbackObserver<EnvironmentTelemetryModule, const meshtastic::Status *> nodeStatusObserver =
CallbackObserver<EnvironmentTelemetryModule, const meshtastic::Status *>(this, CallbackObserver<EnvironmentTelemetryModule, const meshtastic::Status *>(this,
@@ -22,7 +25,7 @@ class EnvironmentTelemetryModule : private concurrency::OSThread, public Protobu
public: public:
EnvironmentTelemetryModule() EnvironmentTelemetryModule()
: concurrency::OSThread("EnvironmentTelemetry"), : concurrency::OSThread("EnvironmentTelemetry"), ScanI2CConsumer(),
ProtobufModule("EnvironmentTelemetry", meshtastic_PortNum_TELEMETRY_APP, &meshtastic_Telemetry_msg) ProtobufModule("EnvironmentTelemetry", meshtastic_PortNum_TELEMETRY_APP, &meshtastic_Telemetry_msg)
{ {
lastMeasurementPacket = nullptr; lastMeasurementPacket = nullptr;
@@ -56,6 +59,8 @@ class EnvironmentTelemetryModule : private concurrency::OSThread, public Protobu
meshtastic_AdminMessage *request, meshtastic_AdminMessage *request,
meshtastic_AdminMessage *response) override; meshtastic_AdminMessage *response) override;
void i2cScanFinished(ScanI2C *i2cScanner);
private: private:
bool firstTime = 1; bool firstTime = 1;
meshtastic_MeshPacket *lastMeasurementPacket; meshtastic_MeshPacket *lastMeasurementPacket;
+13 -12
View File
@@ -15,20 +15,16 @@
AHT10Sensor::AHT10Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_AHT10, "AHT10") {} AHT10Sensor::AHT10Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_AHT10, "AHT10") {}
int32_t AHT10Sensor::runOnce() bool AHT10Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
aht10 = Adafruit_AHTX0(); aht10 = Adafruit_AHTX0();
status = aht10.begin(nodeTelemetrySensorsMap[sensorType].second, 0, nodeTelemetrySensorsMap[sensorType].first); status = aht10.begin(bus, 0, dev->address.address);
return initI2CSensor(); initI2CSensor();
return status;
} }
void AHT10Sensor::setup() {}
bool AHT10Sensor::getMetrics(meshtastic_Telemetry *measurement) bool AHT10Sensor::getMetrics(meshtastic_Telemetry *measurement)
{ {
LOG_DEBUG("AHT10 getMetrics"); LOG_DEBUG("AHT10 getMetrics");
@@ -36,11 +32,16 @@ bool AHT10Sensor::getMetrics(meshtastic_Telemetry *measurement)
sensors_event_t humidity, temp; sensors_event_t humidity, temp;
aht10.getEvent(&humidity, &temp); aht10.getEvent(&humidity, &temp);
measurement->variant.environment_metrics.has_temperature = true; // prefer other sensors like bmp280, bmp3xx
measurement->variant.environment_metrics.has_relative_humidity = true; if (!measurement->variant.environment_metrics.has_temperature) {
measurement->variant.environment_metrics.has_temperature = true;
measurement->variant.environment_metrics.temperature = temp.temperature;
}
measurement->variant.environment_metrics.temperature = temp.temperature; if (!measurement->variant.environment_metrics.has_relative_humidity) {
measurement->variant.environment_metrics.relative_humidity = humidity.relative_humidity; measurement->variant.environment_metrics.has_relative_humidity = true;
measurement->variant.environment_metrics.relative_humidity = humidity.relative_humidity;
}
return true; return true;
} }
+1 -4
View File
@@ -15,13 +15,10 @@ class AHT10Sensor : public TelemetrySensor
private: private:
Adafruit_AHTX0 aht10; Adafruit_AHTX0 aht10;
protected:
virtual void setup() override;
public: public:
AHT10Sensor(); AHT10Sensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
@@ -10,13 +10,13 @@
BME280Sensor::BME280Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BME280, "BME280") {} BME280Sensor::BME280Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BME280, "BME280") {}
int32_t BME280Sensor::runOnce() bool BME280Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) { status = bme280.begin(dev->address.address, bus);
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; if (!status) {
return status;
} }
status = bme280.begin(nodeTelemetrySensorsMap[sensorType].first, nodeTelemetrySensorsMap[sensorType].second);
bme280.setSampling(Adafruit_BME280::MODE_FORCED, bme280.setSampling(Adafruit_BME280::MODE_FORCED,
Adafruit_BME280::SAMPLING_X1, // Temp. oversampling Adafruit_BME280::SAMPLING_X1, // Temp. oversampling
@@ -24,11 +24,10 @@ int32_t BME280Sensor::runOnce()
Adafruit_BME280::SAMPLING_X1, // Humidity oversampling Adafruit_BME280::SAMPLING_X1, // Humidity oversampling
Adafruit_BME280::FILTER_OFF, Adafruit_BME280::STANDBY_MS_1000); Adafruit_BME280::FILTER_OFF, Adafruit_BME280::STANDBY_MS_1000);
return initI2CSensor(); initI2CSensor();
return status;
} }
void BME280Sensor::setup() {}
bool BME280Sensor::getMetrics(meshtastic_Telemetry *measurement) bool BME280Sensor::getMetrics(meshtastic_Telemetry *measurement)
{ {
measurement->variant.environment_metrics.has_temperature = true; measurement->variant.environment_metrics.has_temperature = true;
+1 -4
View File
@@ -11,13 +11,10 @@ class BME280Sensor : public TelemetrySensor
private: private:
Adafruit_BME280 bme280; Adafruit_BME280 bme280;
protected:
virtual void setup() override;
public: public:
BME280Sensor(); BME280Sensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
+7 -12
View File
@@ -10,7 +10,7 @@
BME680Sensor::BME680Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BME680, "BME680") {} BME680Sensor::BME680Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BME680, "BME680") {}
int32_t BME680Sensor::runTrigger() int32_t BME680Sensor::runOnce()
{ {
if (!bme680.run()) { if (!bme680.run()) {
checkStatus("runTrigger"); checkStatus("runTrigger");
@@ -18,13 +18,10 @@ int32_t BME680Sensor::runTrigger()
return 35; return 35;
} }
int32_t BME680Sensor::runOnce() bool BME680Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
status = 0;
if (!hasSensor()) { if (!bme680.begin(dev->address.address, *bus))
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
if (!bme680.begin(nodeTelemetrySensorsMap[sensorType].first, *nodeTelemetrySensorsMap[sensorType].second))
checkStatus("begin"); checkStatus("begin");
if (bme680.status == BSEC_OK) { if (bme680.status == BSEC_OK) {
@@ -40,17 +37,15 @@ int32_t BME680Sensor::runOnce()
} }
LOG_INFO("Init sensor: %s with the BSEC Library version %d.%d.%d.%d ", sensorName, bme680.version.major, LOG_INFO("Init sensor: %s with the BSEC Library version %d.%d.%d.%d ", sensorName, bme680.version.major,
bme680.version.minor, bme680.version.major_bugfix, bme680.version.minor_bugfix); bme680.version.minor, bme680.version.major_bugfix, bme680.version.minor_bugfix);
} else {
status = 0;
} }
if (status == 0) if (status == 0)
LOG_DEBUG("BME680Sensor::runOnce: bme680.status %d", bme680.status); LOG_DEBUG("BME680Sensor::runOnce: bme680.status %d", bme680.status);
return initI2CSensor(); initI2CSensor();
return status;
} }
void BME680Sensor::setup() {}
bool BME680Sensor::getMetrics(meshtastic_Telemetry *measurement) bool BME680Sensor::getMetrics(meshtastic_Telemetry *measurement)
{ {
if (bme680.getData(BSEC_OUTPUT_RAW_PRESSURE).signal == 0) if (bme680.getData(BSEC_OUTPUT_RAW_PRESSURE).signal == 0)
+1 -2
View File
@@ -18,7 +18,6 @@ class BME680Sensor : public TelemetrySensor
Bsec2 bme680; Bsec2 bme680;
protected: protected:
virtual void setup() override;
const char *bsecConfigFileName = "/prefs/bsec.dat"; const char *bsecConfigFileName = "/prefs/bsec.dat";
uint8_t bsecState[BSEC_MAX_STATE_BLOB_SIZE] = {0}; uint8_t bsecState[BSEC_MAX_STATE_BLOB_SIZE] = {0};
uint8_t accuracy = 0; uint8_t accuracy = 0;
@@ -38,9 +37,9 @@ class BME680Sensor : public TelemetrySensor
public: public:
BME680Sensor(); BME680Sensor();
int32_t runTrigger();
virtual int32_t runOnce() override; virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
@@ -10,20 +10,17 @@
BMP085Sensor::BMP085Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BMP085, "BMP085") {} BMP085Sensor::BMP085Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BMP085, "BMP085") {}
int32_t BMP085Sensor::runOnce() bool BMP085Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
bmp085 = Adafruit_BMP085(); bmp085 = Adafruit_BMP085();
status = bmp085.begin(nodeTelemetrySensorsMap[sensorType].first, nodeTelemetrySensorsMap[sensorType].second); status = bmp085.begin(dev->address.address, bus);
return initI2CSensor(); initI2CSensor();
return status;
} }
void BMP085Sensor::setup() {}
bool BMP085Sensor::getMetrics(meshtastic_Telemetry *measurement) bool BMP085Sensor::getMetrics(meshtastic_Telemetry *measurement)
{ {
measurement->variant.environment_metrics.has_temperature = true; measurement->variant.environment_metrics.has_temperature = true;
+1 -4
View File
@@ -11,13 +11,10 @@ class BMP085Sensor : public TelemetrySensor
private: private:
Adafruit_BMP085 bmp085; Adafruit_BMP085 bmp085;
protected:
virtual void setup() override;
public: public:
BMP085Sensor(); BMP085Sensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
@@ -10,25 +10,25 @@
BMP280Sensor::BMP280Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BMP280, "BMP280") {} BMP280Sensor::BMP280Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BMP280, "BMP280") {}
int32_t BMP280Sensor::runOnce() bool BMP280Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; bmp280 = Adafruit_BMP280(bus);
status = bmp280.begin(dev->address.address);
if (!status) {
return status;
} }
bmp280 = Adafruit_BMP280(nodeTelemetrySensorsMap[sensorType].second);
status = bmp280.begin(nodeTelemetrySensorsMap[sensorType].first);
bmp280.setSampling(Adafruit_BMP280::MODE_FORCED, bmp280.setSampling(Adafruit_BMP280::MODE_FORCED,
Adafruit_BMP280::SAMPLING_X1, // Temp. oversampling Adafruit_BMP280::SAMPLING_X1, // Temp. oversampling
Adafruit_BMP280::SAMPLING_X1, // Pressure oversampling Adafruit_BMP280::SAMPLING_X1, // Pressure oversampling
Adafruit_BMP280::FILTER_OFF, Adafruit_BMP280::STANDBY_MS_1000); Adafruit_BMP280::FILTER_OFF, Adafruit_BMP280::STANDBY_MS_1000);
return initI2CSensor(); initI2CSensor();
return status;
} }
void BMP280Sensor::setup() {}
bool BMP280Sensor::getMetrics(meshtastic_Telemetry *measurement) bool BMP280Sensor::getMetrics(meshtastic_Telemetry *measurement)
{ {
measurement->variant.environment_metrics.has_temperature = true; measurement->variant.environment_metrics.has_temperature = true;
+1 -4
View File
@@ -11,13 +11,10 @@ class BMP280Sensor : public TelemetrySensor
private: private:
Adafruit_BMP280 bmp280; Adafruit_BMP280 bmp280;
protected:
virtual void setup() override;
public: public:
BMP280Sensor(); BMP280Sensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
@@ -6,20 +6,18 @@
BMP3XXSensor::BMP3XXSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BMP3XX, "BMP3XX") {} BMP3XXSensor::BMP3XXSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_BMP3XX, "BMP3XX") {}
void BMP3XXSensor::setup() {} bool BMP3XXSensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
int32_t BMP3XXSensor::runOnce()
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
// Get a singleton instance and initialise the bmp3xx // Get a singleton instance and initialise the bmp3xx
if (bmp3xx == nullptr) { if (bmp3xx == nullptr) {
bmp3xx = BMP3XXSingleton::GetInstance(); bmp3xx = BMP3XXSingleton::GetInstance();
} }
status = bmp3xx->begin_I2C(nodeTelemetrySensorsMap[sensorType].first, nodeTelemetrySensorsMap[sensorType].second); status = bmp3xx->begin_I2C(dev->address.address, bus);
if (!status) {
return status;
}
// set up oversampling and filter initialization // set up oversampling and filter initialization
bmp3xx->setTemperatureOversampling(BMP3_OVERSAMPLING_4X); bmp3xx->setTemperatureOversampling(BMP3_OVERSAMPLING_4X);
@@ -31,7 +29,8 @@ int32_t BMP3XXSensor::runOnce()
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
bmp3xx->performReading(); bmp3xx->performReading();
} }
return initI2CSensor(); initI2CSensor();
return status;
} }
bool BMP3XXSensor::getMetrics(meshtastic_Telemetry *measurement) bool BMP3XXSensor::getMetrics(meshtastic_Telemetry *measurement)
+1 -2
View File
@@ -43,12 +43,11 @@ class BMP3XXSensor : public TelemetrySensor
{ {
protected: protected:
BMP3XXSingleton *bmp3xx = nullptr; BMP3XXSingleton *bmp3xx = nullptr;
virtual void setup() override;
public: public:
BMP3XXSensor(); BMP3XXSensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
@@ -14,22 +14,16 @@
CGRadSensSensor::CGRadSensSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_RADSENS, "RadSens") {} CGRadSensSensor::CGRadSensSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_RADSENS, "RadSens") {}
int32_t CGRadSensSensor::runOnce() bool CGRadSensSensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
// Initialize the sensor following the same pattern as RCWL9620Sensor // Initialize the sensor following the same pattern as RCWL9620Sensor
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
status = true; status = true;
begin(nodeTelemetrySensorsMap[sensorType].second, nodeTelemetrySensorsMap[sensorType].first); begin(bus, dev->address.address);
initI2CSensor();
return initI2CSensor(); return status;
} }
void CGRadSensSensor::setup() {}
void CGRadSensSensor::begin(TwoWire *wire, uint8_t addr) void CGRadSensSensor::begin(TwoWire *wire, uint8_t addr)
{ {
// Store the Wire and address to the sensor following the same pattern as RCWL9620Sensor // Store the Wire and address to the sensor following the same pattern as RCWL9620Sensor
@@ -17,14 +17,13 @@ class CGRadSensSensor : public TelemetrySensor
TwoWire *_wire = &Wire; TwoWire *_wire = &Wire;
protected: protected:
virtual void setup() override;
void begin(TwoWire *wire = &Wire, uint8_t addr = 0x66); void begin(TwoWire *wire = &Wire, uint8_t addr = 0x66);
float getStaticRadiation(); float getStaticRadiation();
public: public:
CGRadSensSensor(); CGRadSensSensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
@@ -10,31 +10,39 @@
DFRobotGravitySensor::DFRobotGravitySensor() : TelemetrySensor(meshtastic_TelemetrySensorType_DFROBOT_RAIN, "DFROBOT_RAIN") {} DFRobotGravitySensor::DFRobotGravitySensor() : TelemetrySensor(meshtastic_TelemetrySensorType_DFROBOT_RAIN, "DFROBOT_RAIN") {}
int32_t DFRobotGravitySensor::runOnce() DFRobotGravitySensor::~DFRobotGravitySensor()
{ {
LOG_INFO("Init sensor: %s", sensorName); if (gravity) {
if (!hasSensor()) { delete gravity;
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; gravity = nullptr;
} }
gravity = DFRobot_RainfallSensor_I2C(nodeTelemetrySensorsMap[sensorType].second);
status = gravity.begin();
return initI2CSensor();
} }
void DFRobotGravitySensor::setup() bool DFRobotGravitySensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_DEBUG("%s VID: %x, PID: %x, Version: %s", sensorName, gravity.vid, gravity.pid, gravity.getFirmwareVersion().c_str()); LOG_INFO("Init sensor: %s", sensorName);
gravity = new DFRobot_RainfallSensor_I2C(bus);
status = gravity->begin();
LOG_DEBUG("%s VID: %x, PID: %x, Version: %s", sensorName, gravity->vid, gravity->pid, gravity->getFirmwareVersion().c_str());
initI2CSensor();
return status;
} }
bool DFRobotGravitySensor::getMetrics(meshtastic_Telemetry *measurement) bool DFRobotGravitySensor::getMetrics(meshtastic_Telemetry *measurement)
{ {
if (!gravity) {
LOG_ERROR("DFRobotGravitySensor not initialized");
return false;
}
measurement->variant.environment_metrics.has_rainfall_1h = true; measurement->variant.environment_metrics.has_rainfall_1h = true;
measurement->variant.environment_metrics.has_rainfall_24h = true; measurement->variant.environment_metrics.has_rainfall_24h = true;
measurement->variant.environment_metrics.rainfall_1h = gravity.getRainfall(1); measurement->variant.environment_metrics.rainfall_1h = gravity->getRainfall(1);
measurement->variant.environment_metrics.rainfall_24h = gravity.getRainfall(24); measurement->variant.environment_metrics.rainfall_24h = gravity->getRainfall(24);
LOG_INFO("Rain 1h: %f mm", measurement->variant.environment_metrics.rainfall_1h); LOG_INFO("Rain 1h: %f mm", measurement->variant.environment_metrics.rainfall_1h);
LOG_INFO("Rain 24h: %f mm", measurement->variant.environment_metrics.rainfall_24h); LOG_INFO("Rain 24h: %f mm", measurement->variant.environment_metrics.rainfall_24h);
@@ -14,15 +14,13 @@
class DFRobotGravitySensor : public TelemetrySensor class DFRobotGravitySensor : public TelemetrySensor
{ {
private: private:
DFRobot_RainfallSensor_I2C gravity = DFRobot_RainfallSensor_I2C(nodeTelemetrySensorsMap[sensorType].second); DFRobot_RainfallSensor_I2C *gravity = nullptr;
protected:
virtual void setup() override;
public: public:
DFRobotGravitySensor(); DFRobotGravitySensor();
virtual int32_t runOnce() override; ~DFRobotGravitySensor();
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
@@ -11,14 +11,10 @@
DFRobotLarkSensor::DFRobotLarkSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_DFROBOT_LARK, "DFROBOT_LARK") {} DFRobotLarkSensor::DFRobotLarkSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_DFROBOT_LARK, "DFROBOT_LARK") {}
int32_t DFRobotLarkSensor::runOnce() bool DFRobotLarkSensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) { lark = DFRobot_LarkWeatherStation_I2C(dev->address.address, bus);
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
lark = DFRobot_LarkWeatherStation_I2C(nodeTelemetrySensorsMap[sensorType].first, nodeTelemetrySensorsMap[sensorType].second);
if (lark.begin() == 0) // DFRobotLarkSensor init if (lark.begin() == 0) // DFRobotLarkSensor init
{ {
@@ -28,11 +24,10 @@ int32_t DFRobotLarkSensor::runOnce()
LOG_ERROR("DFRobotLarkSensor Init Failed"); LOG_ERROR("DFRobotLarkSensor Init Failed");
status = false; status = false;
} }
return initI2CSensor(); initI2CSensor();
return status;
} }
void DFRobotLarkSensor::setup() {}
bool DFRobotLarkSensor::getMetrics(meshtastic_Telemetry *measurement) bool DFRobotLarkSensor::getMetrics(meshtastic_Telemetry *measurement)
{ {
measurement->variant.environment_metrics.has_temperature = true; measurement->variant.environment_metrics.has_temperature = true;
@@ -16,13 +16,10 @@ class DFRobotLarkSensor : public TelemetrySensor
private: private:
DFRobot_LarkWeatherStation_I2C lark = DFRobot_LarkWeatherStation_I2C(); DFRobot_LarkWeatherStation_I2C lark = DFRobot_LarkWeatherStation_I2C();
protected:
virtual void setup() override;
public: public:
DFRobotLarkSensor(); DFRobotLarkSensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
@@ -9,23 +9,22 @@
DPS310Sensor::DPS310Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_DPS310, "DPS310") {} DPS310Sensor::DPS310Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_DPS310, "DPS310") {}
int32_t DPS310Sensor::runOnce() bool DPS310Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) { status = dps310.begin_I2C(dev->address.address, bus);
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; if (!status) {
return status;
} }
status = dps310.begin_I2C(nodeTelemetrySensorsMap[sensorType].first, nodeTelemetrySensorsMap[sensorType].second);
dps310.configurePressure(DPS310_1HZ, DPS310_4SAMPLES); dps310.configurePressure(DPS310_1HZ, DPS310_4SAMPLES);
dps310.configureTemperature(DPS310_1HZ, DPS310_4SAMPLES); dps310.configureTemperature(DPS310_1HZ, DPS310_4SAMPLES);
dps310.setMode(DPS310_CONT_PRESTEMP); dps310.setMode(DPS310_CONT_PRESTEMP);
return initI2CSensor(); initI2CSensor();
return status;
} }
void DPS310Sensor::setup() {}
bool DPS310Sensor::getMetrics(meshtastic_Telemetry *measurement) bool DPS310Sensor::getMetrics(meshtastic_Telemetry *measurement)
{ {
sensors_event_t temp, press; sensors_event_t temp, press;
+1 -4
View File
@@ -11,13 +11,10 @@ class DPS310Sensor : public TelemetrySensor
private: private:
Adafruit_DPS310 dps310; Adafruit_DPS310 dps310;
protected:
virtual void setup() override;
public: public:
DPS310Sensor(); DPS310Sensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
@@ -61,11 +61,11 @@ static int cmd_send(uint8_t cmd, const char *p_data, uint8_t len)
return -1; return -1;
} }
int32_t IndicatorSensor::runOnce() bool IndicatorSensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("%s: init", sensorName); LOG_INFO("%s: init", sensorName);
setup(); setup();
return 2 * DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; // give it some time to start up return true;
} }
void IndicatorSensor::setup() void IndicatorSensor::setup()
@@ -7,13 +7,13 @@
class IndicatorSensor : public TelemetrySensor class IndicatorSensor : public TelemetrySensor
{ {
protected:
virtual void setup() override;
public: public:
IndicatorSensor(); IndicatorSensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
private:
void setup();
}; };
#endif #endif
@@ -10,19 +10,17 @@
LPS22HBSensor::LPS22HBSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_LPS22, "LPS22HB") {} LPS22HBSensor::LPS22HBSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_LPS22, "LPS22HB") {}
int32_t LPS22HBSensor::runOnce() bool LPS22HBSensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) { status = lps22hb.begin_I2C(dev->address.address, bus);
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; if (!status) {
return status;
} }
status = lps22hb.begin_I2C(nodeTelemetrySensorsMap[sensorType].first, nodeTelemetrySensorsMap[sensorType].second);
return initI2CSensor();
}
void LPS22HBSensor::setup()
{
lps22hb.setDataRate(LPS22_RATE_10_HZ); lps22hb.setDataRate(LPS22_RATE_10_HZ);
initI2CSensor();
return status;
} }
bool LPS22HBSensor::getMetrics(meshtastic_Telemetry *measurement) bool LPS22HBSensor::getMetrics(meshtastic_Telemetry *measurement)
+1 -4
View File
@@ -12,13 +12,10 @@ class LPS22HBSensor : public TelemetrySensor
private: private:
Adafruit_LPS22 lps22hb; Adafruit_LPS22 lps22hb;
protected:
virtual void setup() override;
public: public:
LPS22HBSensor(); LPS22HBSensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
@@ -9,23 +9,23 @@
LTR390UVSensor::LTR390UVSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_LTR390UV, "LTR390UV") {} LTR390UVSensor::LTR390UVSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_LTR390UV, "LTR390UV") {}
int32_t LTR390UVSensor::runOnce() bool LTR390UVSensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; status = ltr390uv.begin(bus);
if (!status) {
return status;
} }
status = ltr390uv.begin(nodeTelemetrySensorsMap[sensorType].second);
ltr390uv.setMode(LTR390_MODE_UVS); ltr390uv.setMode(LTR390_MODE_UVS);
ltr390uv.setGain(LTR390_GAIN_18); // Datasheet default ltr390uv.setGain(LTR390_GAIN_18); // Datasheet default
ltr390uv.setResolution(LTR390_RESOLUTION_20BIT); // Datasheet default ltr390uv.setResolution(LTR390_RESOLUTION_20BIT); // Datasheet default
return initI2CSensor(); initI2CSensor();
return status;
} }
void LTR390UVSensor::setup() {}
bool LTR390UVSensor::getMetrics(meshtastic_Telemetry *measurement) bool LTR390UVSensor::getMetrics(meshtastic_Telemetry *measurement)
{ {
LOG_DEBUG("LTR390UV getMetrics"); LOG_DEBUG("LTR390UV getMetrics");
@@ -13,13 +13,10 @@ class LTR390UVSensor : public TelemetrySensor
float lastLuxReading = 0; float lastLuxReading = 0;
float lastUVReading = 0; float lastUVReading = 0;
protected:
virtual void setup() override;
public: public:
LTR390UVSensor(); LTR390UVSensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
@@ -9,19 +9,17 @@
MCP9808Sensor::MCP9808Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_MCP9808, "MCP9808") {} MCP9808Sensor::MCP9808Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_MCP9808, "MCP9808") {}
int32_t MCP9808Sensor::runOnce() bool MCP9808Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) { status = mcp9808.begin(dev->address.address, bus);
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; if (!status) {
return status;
} }
status = mcp9808.begin(nodeTelemetrySensorsMap[sensorType].first, nodeTelemetrySensorsMap[sensorType].second);
return initI2CSensor();
}
void MCP9808Sensor::setup()
{
mcp9808.setResolution(2); mcp9808.setResolution(2);
initI2CSensor();
return status;
} }
bool MCP9808Sensor::getMetrics(meshtastic_Telemetry *measurement) bool MCP9808Sensor::getMetrics(meshtastic_Telemetry *measurement)
+1 -4
View File
@@ -11,13 +11,10 @@ class MCP9808Sensor : public TelemetrySensor
private: private:
Adafruit_MCP9808 mcp9808; Adafruit_MCP9808 mcp9808;
protected:
virtual void setup() override;
public: public:
MCP9808Sensor(); MCP9808Sensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
@@ -8,16 +8,12 @@
MLX90632Sensor::MLX90632Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_MLX90632, "MLX90632") {} MLX90632Sensor::MLX90632Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_MLX90632, "MLX90632") {}
int32_t MLX90632Sensor::runOnce() bool MLX90632Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
MLX90632::status returnError; MLX90632::status returnError;
if (mlx.begin(nodeTelemetrySensorsMap[sensorType].first, *nodeTelemetrySensorsMap[sensorType].second, returnError) == if (mlx.begin(dev->address.address, *bus, returnError) == true) // MLX90632 init
true) // MLX90632 init
{ {
LOG_DEBUG("MLX90632 Init Succeed"); LOG_DEBUG("MLX90632 Init Succeed");
status = true; status = true;
@@ -25,11 +21,10 @@ int32_t MLX90632Sensor::runOnce()
LOG_ERROR("MLX90632 Init Failed"); LOG_ERROR("MLX90632 Init Failed");
status = false; status = false;
} }
return initI2CSensor(); initI2CSensor();
return status;
} }
void MLX90632Sensor::setup() {}
bool MLX90632Sensor::getMetrics(meshtastic_Telemetry *measurement) bool MLX90632Sensor::getMetrics(meshtastic_Telemetry *measurement)
{ {
measurement->variant.environment_metrics.has_temperature = true; measurement->variant.environment_metrics.has_temperature = true;
@@ -11,13 +11,10 @@ class MLX90632Sensor : public TelemetrySensor
private: private:
MLX90632 mlx = MLX90632(); MLX90632 mlx = MLX90632();
protected:
virtual void setup() override;
public: public:
MLX90632Sensor(); MLX90632Sensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
@@ -16,24 +16,23 @@ meshtastic_Nau7802Config nau7802config = meshtastic_Nau7802Config_init_zero;
NAU7802Sensor::NAU7802Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_NAU7802, "NAU7802") {} NAU7802Sensor::NAU7802Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_NAU7802, "NAU7802") {}
int32_t NAU7802Sensor::runOnce() bool NAU7802Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) { status = nau7802.begin(*bus);
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; if (!status) {
return status;
} }
status = nau7802.begin(*nodeTelemetrySensorsMap[sensorType].second);
nau7802.setSampleRate(NAU7802_SPS_320); nau7802.setSampleRate(NAU7802_SPS_320);
if (!loadCalibrationData()) { if (!loadCalibrationData()) {
LOG_ERROR("Failed to load calibration data"); LOG_ERROR("Failed to load calibration data");
} }
nau7802.calibrateAFE(); nau7802.calibrateAFE();
LOG_INFO("Offset: %d, Calibration factor: %.2f", nau7802.getZeroOffset(), nau7802.getCalibrationFactor()); LOG_INFO("Offset: %d, Calibration factor: %.2f", nau7802.getZeroOffset(), nau7802.getCalibrationFactor());
return initI2CSensor(); initI2CSensor();
return status;
} }
void NAU7802Sensor::setup() {}
bool NAU7802Sensor::getMetrics(meshtastic_Telemetry *measurement) bool NAU7802Sensor::getMetrics(meshtastic_Telemetry *measurement)
{ {
LOG_DEBUG("NAU7802 getMetrics"); LOG_DEBUG("NAU7802 getMetrics");
+1 -2
View File
@@ -13,15 +13,14 @@ class NAU7802Sensor : public TelemetrySensor
NAU7802 nau7802; NAU7802 nau7802;
protected: protected:
virtual void setup() override;
const char *nau7802ConfigFileName = "/prefs/nau7802.dat"; const char *nau7802ConfigFileName = "/prefs/nau7802.dat";
bool saveCalibrationData(); bool saveCalibrationData();
bool loadCalibrationData(); bool loadCalibrationData();
public: public:
NAU7802Sensor(); NAU7802Sensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
void tare(); void tare();
void calibrate(float weight); void calibrate(float weight);
AdminMessageHandleResult handleAdminMessage(const meshtastic_MeshPacket &mp, meshtastic_AdminMessage *request, AdminMessageHandleResult handleAdminMessage(const meshtastic_MeshPacket &mp, meshtastic_AdminMessage *request,
+9 -10
View File
@@ -9,20 +9,15 @@
OPT3001Sensor::OPT3001Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_OPT3001, "OPT3001") {} OPT3001Sensor::OPT3001Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_OPT3001, "OPT3001") {}
int32_t OPT3001Sensor::runOnce() bool OPT3001Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) { auto errorCode = opt3001.begin(dev->address.address);
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
auto errorCode = opt3001.begin(nodeTelemetrySensorsMap[sensorType].first);
status = errorCode == NO_ERROR; status = errorCode == NO_ERROR;
if (!status) {
return status;
}
return initI2CSensor();
}
void OPT3001Sensor::setup()
{
OPT3001_Config newConfig; OPT3001_Config newConfig;
newConfig.RangeNumber = 0b1100; newConfig.RangeNumber = 0b1100;
@@ -34,6 +29,10 @@ void OPT3001Sensor::setup()
if (errorConfig != NO_ERROR) { if (errorConfig != NO_ERROR) {
LOG_ERROR("OPT3001 configuration error #%d", errorConfig); LOG_ERROR("OPT3001 configuration error #%d", errorConfig);
} }
status = errorConfig == NO_ERROR;
initI2CSensor();
return status;
} }
bool OPT3001Sensor::getMetrics(meshtastic_Telemetry *measurement) bool OPT3001Sensor::getMetrics(meshtastic_Telemetry *measurement)
+4 -4
View File
@@ -12,13 +12,13 @@ class OPT3001Sensor : public TelemetrySensor
private: private:
ClosedCube_OPT3001 opt3001; ClosedCube_OPT3001 opt3001;
protected:
virtual void setup() override;
public: public:
OPT3001Sensor(); OPT3001Sensor();
virtual int32_t runOnce() override; #if WIRE_INTERFACES_COUNT > 1
virtual bool onlyWire1() { return true; }
#endif
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
+4 -10
View File
@@ -9,24 +9,18 @@
PCT2075Sensor::PCT2075Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_PCT2075, "PCT2075") {} PCT2075Sensor::PCT2075Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_PCT2075, "PCT2075") {}
int32_t PCT2075Sensor::runOnce() bool PCT2075Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) { status = pct2075.begin(dev->address.address, bus);
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
status = pct2075.begin(nodeTelemetrySensorsMap[sensorType].first, nodeTelemetrySensorsMap[sensorType].second); initI2CSensor();
return status;
return initI2CSensor();
} }
void PCT2075Sensor::setup() {}
bool PCT2075Sensor::getMetrics(meshtastic_Telemetry *measurement) bool PCT2075Sensor::getMetrics(meshtastic_Telemetry *measurement)
{ {
measurement->variant.environment_metrics.has_temperature = true; measurement->variant.environment_metrics.has_temperature = true;
measurement->variant.environment_metrics.temperature = pct2075.getTemperature(); measurement->variant.environment_metrics.temperature = pct2075.getTemperature();
return true; return true;
+1 -4
View File
@@ -12,13 +12,10 @@ class PCT2075Sensor : public TelemetrySensor
private: private:
Adafruit_PCT2075 pct2075; Adafruit_PCT2075 pct2075;
protected:
virtual void setup() override;
public: public:
PCT2075Sensor(); PCT2075Sensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
@@ -6,16 +6,12 @@
RAK12035Sensor::RAK12035Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_RAK12035, "RAK12035") {} RAK12035Sensor::RAK12035Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_RAK12035, "RAK12035") {}
int32_t RAK12035Sensor::runOnce() bool RAK12035Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
// TODO:: check for up to 2 additional sensors and start them if present. // TODO:: check for up to 2 additional sensors and start them if present.
sensor.set_sensor_addr(RAK120351_ADDR); sensor.set_sensor_addr(RAK120351_ADDR);
delay(100); delay(100);
sensor.begin(nodeTelemetrySensorsMap[sensorType].first); sensor.begin(dev->address.address);
// Get sensor firmware version // Get sensor firmware version
uint8_t data = 0; uint8_t data = 0;
@@ -31,8 +27,13 @@ int32_t RAK12035Sensor::runOnce()
LOG_ERROR("RAK12035Sensor Init Failed"); LOG_ERROR("RAK12035Sensor Init Failed");
status = false; status = false;
} }
if (!status) {
return status;
}
setup();
return initI2CSensor(); initI2CSensor();
return status;
} }
void RAK12035Sensor::setup() void RAK12035Sensor::setup()
@@ -16,13 +16,14 @@ class RAK12035Sensor : public TelemetrySensor
{ {
private: private:
RAK12035 sensor; RAK12035 sensor;
void setup();
protected:
virtual void setup() override;
public: public:
RAK12035Sensor(); RAK12035Sensor();
virtual int32_t runOnce() override; #if WIRE_INTERFACES_COUNT > 1
virtual bool onlyWire1() { return true; }
#endif
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
@@ -8,19 +8,15 @@
RCWL9620Sensor::RCWL9620Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_RCWL9620, "RCWL9620") {} RCWL9620Sensor::RCWL9620Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_RCWL9620, "RCWL9620") {}
int32_t RCWL9620Sensor::runOnce() bool RCWL9620Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
status = 1; status = 1;
begin(nodeTelemetrySensorsMap[sensorType].second, nodeTelemetrySensorsMap[sensorType].first); begin(bus, dev->address.address);
return initI2CSensor(); initI2CSensor();
return status;
} }
void RCWL9620Sensor::setup() {}
bool RCWL9620Sensor::getMetrics(meshtastic_Telemetry *measurement) bool RCWL9620Sensor::getMetrics(meshtastic_Telemetry *measurement)
{ {
measurement->variant.environment_metrics.has_distance = true; measurement->variant.environment_metrics.has_distance = true;
@@ -16,14 +16,13 @@ class RCWL9620Sensor : public TelemetrySensor
uint32_t _speed = 200000UL; uint32_t _speed = 200000UL;
protected: protected:
virtual void setup() override;
void begin(TwoWire *wire = &Wire, uint8_t addr = 0x57, uint8_t sda = -1, uint8_t scl = -1, uint32_t speed = 200000UL); void begin(TwoWire *wire = &Wire, uint8_t addr = 0x57, uint8_t sda = -1, uint8_t scl = -1, uint32_t speed = 200000UL);
float getDistance(); float getDistance();
public: public:
RCWL9620Sensor(); RCWL9620Sensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
+5 -12
View File
@@ -9,20 +9,13 @@
SHT31Sensor::SHT31Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SHT31, "SHT31") {} SHT31Sensor::SHT31Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SHT31, "SHT31") {}
int32_t SHT31Sensor::runOnce() bool SHT31Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) { sht31 = Adafruit_SHT31(bus);
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; status = sht31.begin(dev->address.address);
} initI2CSensor();
sht31 = Adafruit_SHT31(nodeTelemetrySensorsMap[sensorType].second); return status;
status = sht31.begin(nodeTelemetrySensorsMap[sensorType].first);
return initI2CSensor();
}
void SHT31Sensor::setup()
{
// Set up oversampling and filter initialization
} }
bool SHT31Sensor::getMetrics(meshtastic_Telemetry *measurement) bool SHT31Sensor::getMetrics(meshtastic_Telemetry *measurement)
+1 -4
View File
@@ -11,13 +11,10 @@ class SHT31Sensor : public TelemetrySensor
private: private:
Adafruit_SHT31 sht31; Adafruit_SHT31 sht31;
protected:
virtual void setup() override;
public: public:
SHT31Sensor(); SHT31Sensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
+7 -11
View File
@@ -9,16 +9,16 @@
SHT4XSensor::SHT4XSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SHT4X, "SHT4X") {} SHT4XSensor::SHT4XSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SHT4X, "SHT4X") {}
int32_t SHT4XSensor::runOnce() bool SHT4XSensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
uint32_t serialNumber = 0; uint32_t serialNumber = 0;
sht4x.begin(nodeTelemetrySensorsMap[sensorType].second); status = sht4x.begin(bus);
if (!status) {
return status;
}
serialNumber = sht4x.readSerial(); serialNumber = sht4x.readSerial();
if (serialNumber != 0) { if (serialNumber != 0) {
@@ -29,12 +29,8 @@ int32_t SHT4XSensor::runOnce()
status = 0; status = 0;
} }
return initI2CSensor(); initI2CSensor();
} return status;
void SHT4XSensor::setup()
{
// Set up oversampling and filter initialization
} }
bool SHT4XSensor::getMetrics(meshtastic_Telemetry *measurement) bool SHT4XSensor::getMetrics(meshtastic_Telemetry *measurement)
+1 -4
View File
@@ -11,13 +11,10 @@ class SHT4XSensor : public TelemetrySensor
private: private:
Adafruit_SHT4x sht4x = Adafruit_SHT4x(); Adafruit_SHT4x sht4x = Adafruit_SHT4x();
protected:
virtual void setup() override;
public: public:
SHT4XSensor(); SHT4XSensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
+4 -10
View File
@@ -9,19 +9,13 @@
SHTC3Sensor::SHTC3Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SHTC3, "SHTC3") {} SHTC3Sensor::SHTC3Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SHTC3, "SHTC3") {}
int32_t SHTC3Sensor::runOnce() bool SHTC3Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) { status = shtc3.begin(bus);
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
status = shtc3.begin(nodeTelemetrySensorsMap[sensorType].second);
return initI2CSensor();
}
void SHTC3Sensor::setup() initI2CSensor();
{ return status;
// Set up oversampling and filter initialization
} }
bool SHTC3Sensor::getMetrics(meshtastic_Telemetry *measurement) bool SHTC3Sensor::getMetrics(meshtastic_Telemetry *measurement)
+1 -4
View File
@@ -11,13 +11,10 @@ class SHTC3Sensor : public TelemetrySensor
private: private:
Adafruit_SHTC3 shtc3 = Adafruit_SHTC3(); Adafruit_SHTC3 shtc3 = Adafruit_SHTC3();
protected:
virtual void setup() override;
public: public:
SHTC3Sensor(); SHTC3Sensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
+2 -10
View File
@@ -38,18 +38,10 @@ int8_t ntc_temp2[136] = {
T1000xSensor::T1000xSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SENSOR_UNSET, "T1000x") {} T1000xSensor::T1000xSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SENSOR_UNSET, "T1000x") {}
int32_t T1000xSensor::runOnce() bool T1000xSensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) { return true;
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
}
void T1000xSensor::setup()
{
// Set up oversampling and filter initialization
} }
float T1000xSensor::getLux() float T1000xSensor::getLux()
+1 -4
View File
@@ -7,13 +7,10 @@
class T1000xSensor : public TelemetrySensor class T1000xSensor : public TelemetrySensor
{ {
protected:
virtual void setup() override;
public: public:
T1000xSensor(); T1000xSensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
virtual float getLux(); virtual float getLux();
virtual float getTemp(); virtual float getTemp();
}; };
+8 -11
View File
@@ -9,22 +9,19 @@
TSL2561Sensor::TSL2561Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_TSL2561, "TSL2561") {} TSL2561Sensor::TSL2561Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_TSL2561, "TSL2561") {}
int32_t TSL2561Sensor::runOnce() bool TSL2561Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) {
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; status = tsl.begin(bus);
if (!status) {
return status;
} }
status = tsl.begin(nodeTelemetrySensorsMap[sensorType].second);
return initI2CSensor();
}
void TSL2561Sensor::setup()
{
tsl.setGain(TSL2561_GAIN_1X); tsl.setGain(TSL2561_GAIN_1X);
tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_101MS); tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_101MS);
initI2CSensor();
return status;
} }
bool TSL2561Sensor::getMetrics(meshtastic_Telemetry *measurement) bool TSL2561Sensor::getMetrics(meshtastic_Telemetry *measurement)
+1 -4
View File
@@ -12,12 +12,9 @@ class TSL2561Sensor : public TelemetrySensor
// The magic number is a sensor id, the actual value doesn't matter // The magic number is a sensor id, the actual value doesn't matter
Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_LOW, 12345); Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_LOW, 12345);
protected:
virtual void setup() override;
public: public:
TSL2561Sensor(); TSL2561Sensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
+7 -10
View File
@@ -10,21 +10,18 @@
TSL2591Sensor::TSL2591Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_TSL25911FN, "TSL2591") {} TSL2591Sensor::TSL2591Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_TSL25911FN, "TSL2591") {}
int32_t TSL2591Sensor::runOnce() bool TSL2591Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) { status = tsl.begin(bus);
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; if (!status) {
return status;
} }
status = tsl.begin(nodeTelemetrySensorsMap[sensorType].second);
return initI2CSensor();
}
void TSL2591Sensor::setup()
{
tsl.setGain(TSL2591_GAIN_LOW); // 1x gain tsl.setGain(TSL2591_GAIN_LOW); // 1x gain
tsl.setTiming(TSL2591_INTEGRATIONTIME_100MS); tsl.setTiming(TSL2591_INTEGRATIONTIME_100MS);
initI2CSensor();
return status;
} }
bool TSL2591Sensor::getMetrics(meshtastic_Telemetry *measurement) bool TSL2591Sensor::getMetrics(meshtastic_Telemetry *measurement)
+1 -4
View File
@@ -11,12 +11,9 @@ class TSL2591Sensor : public TelemetrySensor
private: private:
Adafruit_TSL2591 tsl; Adafruit_TSL2591 tsl;
protected:
virtual void setup() override;
public: public:
TSL2591Sensor(); TSL2591Sensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
+13 -2
View File
@@ -6,6 +6,7 @@
#include "../mesh/generated/meshtastic/telemetry.pb.h" #include "../mesh/generated/meshtastic/telemetry.pb.h"
#include "MeshModule.h" #include "MeshModule.h"
#include "NodeDB.h" #include "NodeDB.h"
#include "detect/ScanI2C.h"
#include <utility> #include <utility>
#if !ARCH_PORTDUINO #if !ARCH_PORTDUINO
@@ -42,22 +43,32 @@ class TelemetrySensor
initialized = true; initialized = true;
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS;
} }
virtual void setup() = 0;
// TODO: check is setup used at all?
virtual void setup() {}
public: public:
virtual ~TelemetrySensor() {}
virtual AdminMessageHandleResult handleAdminMessage(const meshtastic_MeshPacket &mp, meshtastic_AdminMessage *request, virtual AdminMessageHandleResult handleAdminMessage(const meshtastic_MeshPacket &mp, meshtastic_AdminMessage *request,
meshtastic_AdminMessage *response) meshtastic_AdminMessage *response)
{ {
return AdminMessageHandleResult::NOT_HANDLED; return AdminMessageHandleResult::NOT_HANDLED;
} }
// TODO: delete after migration
bool hasSensor() { return nodeTelemetrySensorsMap[sensorType].first > 0; } bool hasSensor() { return nodeTelemetrySensorsMap[sensorType].first > 0; }
virtual int32_t runOnce() = 0; #if WIRE_INTERFACES_COUNT > 1
// Set to true if Implementation only works first I2C port (Wire)
virtual bool onlyWire1() { return false; }
#endif
virtual int32_t runOnce() { return INT32_MAX; }
virtual bool isInitialized() { return initialized; } virtual bool isInitialized() { return initialized; }
virtual bool isRunning() { return status > 0; } virtual bool isRunning() { return status > 0; }
virtual bool getMetrics(meshtastic_Telemetry *measurement) = 0; virtual bool getMetrics(meshtastic_Telemetry *measurement) = 0;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) { return false; };
}; };
#endif #endif
@@ -11,23 +11,22 @@
VEML7700Sensor::VEML7700Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_VEML7700, "VEML7700") {} VEML7700Sensor::VEML7700Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_VEML7700, "VEML7700") {}
int32_t VEML7700Sensor::runOnce() bool VEML7700Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
{ {
LOG_INFO("Init sensor: %s", sensorName); LOG_INFO("Init sensor: %s", sensorName);
if (!hasSensor()) { status = veml7700.begin(bus);
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; if (!status) {
return status;
} }
status = veml7700.begin(nodeTelemetrySensorsMap[sensorType].second);
veml7700.setLowThreshold(10000); veml7700.setLowThreshold(10000);
veml7700.setHighThreshold(20000); veml7700.setHighThreshold(20000);
veml7700.interruptEnable(true); veml7700.interruptEnable(true);
return initI2CSensor(); initI2CSensor();
return status;
} }
void VEML7700Sensor::setup() {}
/*! /*!
* @brief Copmute lux from ALS reading. * @brief Copmute lux from ALS reading.
* @param rawALS raw ALS register value * @param rawALS raw ALS register value
@@ -16,12 +16,9 @@ class VEML7700Sensor : public TelemetrySensor
float computeLux(uint16_t rawALS, bool corrected); float computeLux(uint16_t rawALS, bool corrected);
float getResolution(void); float getResolution(void);
protected:
virtual void setup() override;
public: public:
VEML7700Sensor(); VEML7700Sensor();
virtual int32_t runOnce() override;
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override;
virtual bool initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev) override;
}; };
#endif #endif
+1 -1
View File
@@ -11,7 +11,7 @@ NullSensor::NullSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_SENSOR
int32_t NullSensor::runOnce() int32_t NullSensor::runOnce()
{ {
return 0; return INT32_MAX;
} }
void NullSensor::setup() {} void NullSensor::setup() {}
+3 -1
View File
@@ -473,7 +473,9 @@ bool MQTT::publish(const char *topic, const uint8_t *payload, size_t length, boo
if (moduleConfig.mqtt.proxy_to_client_enabled) { if (moduleConfig.mqtt.proxy_to_client_enabled) {
meshtastic_MqttClientProxyMessage *msg = mqttClientProxyMessagePool.allocZeroed(); meshtastic_MqttClientProxyMessage *msg = mqttClientProxyMessagePool.allocZeroed();
msg->which_payload_variant = meshtastic_MqttClientProxyMessage_data_tag; msg->which_payload_variant = meshtastic_MqttClientProxyMessage_data_tag;
strcpy(msg->topic, topic); strlcpy(msg->topic, topic, sizeof(msg->topic));
if (length > sizeof(msg->payload_variant.data.bytes))
length = sizeof(msg->payload_variant.data.bytes);
msg->payload_variant.data.size = length; msg->payload_variant.data.size = length;
memcpy(msg->payload_variant.data.bytes, payload, length); memcpy(msg->payload_variant.data.bytes, payload, length);
msg->retained = retained; msg->retained = retained;
+105 -8
View File
@@ -17,6 +17,21 @@
#include "PowerStatus.h" #include "PowerStatus.h"
#endif #endif
#if defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C6)
#if defined(CONFIG_NIMBLE_CPP_IDF)
#include "host/ble_gap.h"
#else
#include "nimble/nimble/host/include/host/ble_gap.h"
#endif
namespace
{
constexpr uint16_t kPreferredBleMtu = 517;
constexpr uint16_t kPreferredBleTxOctets = 251;
constexpr uint16_t kPreferredBleTxTimeUs = (kPreferredBleTxOctets + 14) * 8;
} // namespace
#endif
NimBLECharacteristic *fromNumCharacteristic; NimBLECharacteristic *fromNumCharacteristic;
NimBLECharacteristic *BatteryCharacteristic; NimBLECharacteristic *BatteryCharacteristic;
NimBLECharacteristic *logRadioCharacteristic; NimBLECharacteristic *logRadioCharacteristic;
@@ -33,6 +48,8 @@ class BluetoothPhoneAPI : public PhoneAPI, public concurrency::OSThread
uint8_t queue_size = 0; uint8_t queue_size = 0;
uint8_t fromRadioBytes[meshtastic_FromRadio_size] = {0}; uint8_t fromRadioBytes[meshtastic_FromRadio_size] = {0};
size_t numBytes = 0; size_t numBytes = 0;
bool hasChecked = false;
bool phoneWants = false;
protected: protected:
virtual int32_t runOnce() override virtual int32_t runOnce() override
@@ -45,7 +62,11 @@ class BluetoothPhoneAPI : public PhoneAPI, public concurrency::OSThread
LOG_DEBUG("Queue_size %u", queue_size); LOG_DEBUG("Queue_size %u", queue_size);
queue_size = 0; queue_size = 0;
} }
// Note: phoneWants/hasChecked logic removed since onRead() handles getFromRadio() directly if (!hasChecked && phoneWants) {
// Pull fresh data while we're outside of the NimBLE callback context.
numBytes = getFromRadio(fromRadioBytes);
hasChecked = true;
}
// the run is triggered via NimbleBluetoothToRadioCallback and NimbleBluetoothFromRadioCallback // the run is triggered via NimbleBluetoothToRadioCallback and NimbleBluetoothFromRadioCallback
return INT32_MAX; return INT32_MAX;
@@ -102,6 +123,8 @@ class NimbleBluetoothToRadioCallback : public NimBLECharacteristicCallbacks
bluetoothPhoneAPI->queue_size++; bluetoothPhoneAPI->queue_size++;
bluetoothPhoneAPI->setIntervalFromNow(0); bluetoothPhoneAPI->setIntervalFromNow(0);
} }
} else {
LOG_DEBUG("Drop duplicate ToRadio packet (%u bytes)", val.length());
} }
} }
}; };
@@ -114,17 +137,32 @@ class NimbleBluetoothFromRadioCallback : public NimBLECharacteristicCallbacks
virtual void onRead(NimBLECharacteristic *pCharacteristic) virtual void onRead(NimBLECharacteristic *pCharacteristic)
#endif #endif
{ {
bluetoothPhoneAPI->phoneWants = true;
bluetoothPhoneAPI->setIntervalFromNow(0);
std::lock_guard<std::mutex> guard(bluetoothPhoneAPI->nimble_mutex); std::lock_guard<std::mutex> guard(bluetoothPhoneAPI->nimble_mutex);
// Get fresh data immediately when client reads if (!bluetoothPhoneAPI->hasChecked) {
bluetoothPhoneAPI->numBytes = bluetoothPhoneAPI->getFromRadio(bluetoothPhoneAPI->fromRadioBytes); // Fetch payload on demand; prefetch keeps this fast for the first read.
bluetoothPhoneAPI->numBytes = bluetoothPhoneAPI->getFromRadio(bluetoothPhoneAPI->fromRadioBytes);
bluetoothPhoneAPI->hasChecked = true;
}
// Set the characteristic value with whatever data we have
pCharacteristic->setValue(bluetoothPhoneAPI->fromRadioBytes, bluetoothPhoneAPI->numBytes); pCharacteristic->setValue(bluetoothPhoneAPI->fromRadioBytes, bluetoothPhoneAPI->numBytes);
if (bluetoothPhoneAPI->numBytes != 0) {
#ifdef NIMBLE_TWO
// Notify immediately so subscribed clients see the packet without an extra read.
pCharacteristic->notify(bluetoothPhoneAPI->fromRadioBytes, bluetoothPhoneAPI->numBytes, BLE_HS_CONN_HANDLE_NONE);
#else
pCharacteristic->notify();
#endif
}
if (bluetoothPhoneAPI->numBytes != 0) // if we did send something, queue it up right away to reload if (bluetoothPhoneAPI->numBytes != 0) // if we did send something, queue it up right away to reload
bluetoothPhoneAPI->setIntervalFromNow(0); bluetoothPhoneAPI->setIntervalFromNow(0);
bluetoothPhoneAPI->numBytes = 0; bluetoothPhoneAPI->numBytes = 0;
bluetoothPhoneAPI->hasChecked = false;
bluetoothPhoneAPI->phoneWants = false;
} }
}; };
@@ -212,6 +250,27 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
virtual void onConnect(NimBLEServer *pServer, NimBLEConnInfo &connInfo) virtual void onConnect(NimBLEServer *pServer, NimBLEConnInfo &connInfo)
{ {
LOG_INFO("BLE incoming connection %s", connInfo.getAddress().toString().c_str()); LOG_INFO("BLE incoming connection %s", connInfo.getAddress().toString().c_str());
#if defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C6)
const uint16_t connHandle = connInfo.getConnHandle();
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);
}
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);
}
LOG_INFO("BLE conn %u initial MTU %u (target %u)", connHandle, connInfo.getMTU(), kPreferredBleMtu);
pServer->updateConnParams(connHandle, 6, 12, 0, 200);
#endif
} }
virtual void onDisconnect(NimBLEServer *pServer, NimBLEConnInfo &connInfo, int reason) virtual void onDisconnect(NimBLEServer *pServer, NimBLEConnInfo &connInfo, int reason)
@@ -235,6 +294,8 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
bluetoothPhoneAPI->close(); bluetoothPhoneAPI->close();
bluetoothPhoneAPI->numBytes = 0; bluetoothPhoneAPI->numBytes = 0;
bluetoothPhoneAPI->queue_size = 0; bluetoothPhoneAPI->queue_size = 0;
bluetoothPhoneAPI->hasChecked = false;
bluetoothPhoneAPI->phoneWants = false;
} }
// Clear the last ToRadio packet buffer to avoid rejecting first packet from new connection // Clear the last ToRadio packet buffer to avoid rejecting first packet from new connection
@@ -242,6 +303,15 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
#ifdef NIMBLE_TWO #ifdef NIMBLE_TWO
// Restart Advertising // Restart Advertising
ble->startAdvertising(); ble->startAdvertising();
#else
NimBLEAdvertising *pAdvertising = NimBLEDevice::getAdvertising();
if (!pAdvertising->start(0)) {
if (pAdvertising->isAdvertising()) {
LOG_DEBUG("BLE advertising already running");
} else {
LOG_ERROR("BLE failed to restart advertising");
}
}
#endif #endif
} }
}; };
@@ -316,6 +386,30 @@ void NimbleBluetooth::setup()
NimBLEDevice::init(getDeviceName()); NimBLEDevice::init(getDeviceName());
NimBLEDevice::setPower(ESP_PWR_LVL_P9); NimBLEDevice::setPower(ESP_PWR_LVL_P9);
#if defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C6)
int mtuResult = NimBLEDevice::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
if (config.bluetooth.mode != meshtastic_Config_BluetoothConfig_PairingMode_NO_PIN) { 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::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::setSecurityInitKey(BLE_SM_PAIR_KEY_DIST_ENC | BLE_SM_PAIR_KEY_DIST_ID);
@@ -341,15 +435,18 @@ void NimbleBluetooth::setupService()
// Define the characteristics that the app is looking for // Define the characteristics that the app is looking for
if (config.bluetooth.mode == meshtastic_Config_BluetoothConfig_PairingMode_NO_PIN) { if (config.bluetooth.mode == meshtastic_Config_BluetoothConfig_PairingMode_NO_PIN) {
ToRadioCharacteristic = bleService->createCharacteristic(TORADIO_UUID, NIMBLE_PROPERTY::WRITE); ToRadioCharacteristic = bleService->createCharacteristic(TORADIO_UUID, NIMBLE_PROPERTY::WRITE);
FromRadioCharacteristic = bleService->createCharacteristic(FROMRADIO_UUID, NIMBLE_PROPERTY::READ); // Allow notifications so phones can stream FromRadio without polling.
FromRadioCharacteristic =
bleService->createCharacteristic(FROMRADIO_UUID, NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::NOTIFY);
fromNumCharacteristic = bleService->createCharacteristic(FROMNUM_UUID, NIMBLE_PROPERTY::NOTIFY | NIMBLE_PROPERTY::READ); fromNumCharacteristic = bleService->createCharacteristic(FROMNUM_UUID, NIMBLE_PROPERTY::NOTIFY | NIMBLE_PROPERTY::READ);
logRadioCharacteristic = logRadioCharacteristic =
bleService->createCharacteristic(LOGRADIO_UUID, NIMBLE_PROPERTY::NOTIFY | NIMBLE_PROPERTY::READ, 512U); bleService->createCharacteristic(LOGRADIO_UUID, NIMBLE_PROPERTY::NOTIFY | NIMBLE_PROPERTY::READ, 512U);
} else { } else {
ToRadioCharacteristic = bleService->createCharacteristic( ToRadioCharacteristic = bleService->createCharacteristic(
TORADIO_UUID, NIMBLE_PROPERTY::WRITE | NIMBLE_PROPERTY::WRITE_AUTHEN | NIMBLE_PROPERTY::WRITE_ENC); TORADIO_UUID, NIMBLE_PROPERTY::WRITE | NIMBLE_PROPERTY::WRITE_AUTHEN | NIMBLE_PROPERTY::WRITE_ENC);
FromRadioCharacteristic = bleService->createCharacteristic( FromRadioCharacteristic =
FROMRADIO_UUID, NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::READ_AUTHEN | NIMBLE_PROPERTY::READ_ENC); bleService->createCharacteristic(FROMRADIO_UUID, NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::READ_AUTHEN |
NIMBLE_PROPERTY::READ_ENC | NIMBLE_PROPERTY::NOTIFY);
fromNumCharacteristic = fromNumCharacteristic =
bleService->createCharacteristic(FROMNUM_UUID, NIMBLE_PROPERTY::NOTIFY | NIMBLE_PROPERTY::READ | bleService->createCharacteristic(FROMNUM_UUID, NIMBLE_PROPERTY::NOTIFY | NIMBLE_PROPERTY::READ |
NIMBLE_PROPERTY::READ_AUTHEN | NIMBLE_PROPERTY::READ_ENC); NIMBLE_PROPERTY::READ_AUTHEN | NIMBLE_PROPERTY::READ_ENC);
@@ -459,4 +556,4 @@ void clearNVS()
ESP.restart(); ESP.restart();
#endif #endif
} }
#endif #endif
-1
View File
@@ -6,7 +6,6 @@
#define GPS_TX_PIN 15 #define GPS_TX_PIN 15
#define GPS_RX_PIN 12 #define GPS_RX_PIN 12
#define PIN_GPS_EN 4 #define PIN_GPS_EN 4
#define GPS_POWER_TOGGLE // Moved definition from platformio.ini to here
#define BUTTON_PIN 39 // The middle button GPIO on the T-Beam #define BUTTON_PIN 39 // The middle button GPIO on the T-Beam
// Note: On the ESP32 base version, gpio34-39 are input-only, and do not have internal pull-ups. // Note: On the ESP32 base version, gpio34-39 are input-only, and do not have internal pull-ups.
@@ -7,4 +7,3 @@ build_flags =
${esp32_base.build_flags} ${esp32_base.build_flags}
-D HELTEC_V2_1 -D HELTEC_V2_1
-I variants/esp32/heltec_v2.1 -I variants/esp32/heltec_v2.1
-DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely.
@@ -6,4 +6,3 @@ build_flags =
${esp32_base.build_flags} ${esp32_base.build_flags}
-D PRIVATE_HW -D PRIVATE_HW
-I variants/esp32/heltec_wsl_v2.1 -I variants/esp32/heltec_wsl_v2.1
-DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely.
-1
View File
@@ -10,7 +10,6 @@ build_flags =
${esp32_base.build_flags} ${esp32_base.build_flags}
-D TBEAM_V10 -D TBEAM_V10
-I variants/esp32/tbeam -I variants/esp32/tbeam
-DGPS_POWER_TOGGLE ; comment this line to disable double press function on the user button to turn off gps entirely.
-DBOARD_HAS_PSRAM -DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue -mfix-esp32-psram-cache-issue
upload_speed = 921600 upload_speed = 921600
@@ -4,5 +4,4 @@ board = ttgo-lora32-v21
board_check = true board_check = true
build_flags = build_flags =
${esp32_base.build_flags} -D TLORA_V2_1_16 -I variants/esp32/tlora_v2_1_16 ${esp32_base.build_flags} -D TLORA_V2_1_16 -I variants/esp32/tlora_v2_1_16
-DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely.
upload_speed = 115200 upload_speed = 115200
@@ -6,6 +6,5 @@ build_flags =
${esp32_base.build_flags} ${esp32_base.build_flags}
-D TLORA_V2_1_16 -D TLORA_V2_1_16
-I variants/esp32/tlora_v2_1_16 -I variants/esp32/tlora_v2_1_16
-D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely.
-D LORA_TCXO_GPIO=33 -D LORA_TCXO_GPIO=33
upload_speed = 115200 upload_speed = 115200
@@ -5,6 +5,5 @@ build_flags =
${esp32_base.build_flags} ${esp32_base.build_flags}
-D TLORA_V2_1_16 -D TLORA_V2_1_16
-I variants/esp32/tlora_v2_1_16 -I variants/esp32/tlora_v2_1_16
-D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely.
-D LORA_TCXO_GPIO=12 -D LORA_TCXO_GPIO=12
-D BUTTON_PIN=0 -D BUTTON_PIN=0
@@ -5,4 +5,3 @@ build_flags =
${esp32s3_base.build_flags} ${esp32s3_base.build_flags}
-D CDEBYTE_EORA_S3 -D CDEBYTE_EORA_S3
-I variants/esp32s3/CDEBYTE_EoRa-S3 -I variants/esp32s3/CDEBYTE_EoRa-S3
-D GPS_POWER_TOGGLE
@@ -16,7 +16,6 @@ build_flags =
-I variants/esp32s3/crowpanel-esp32s3-5-epaper -I variants/esp32s3/crowpanel-esp32s3-5-epaper
-D PRIVATE_HW -D PRIVATE_HW
-DBOARD_HAS_PSRAM -DBOARD_HAS_PSRAM
-DGPS_POWER_TOGGLE
-DEINK_DISPLAY_MODEL=GxEPD2_579_GDEY0579T93 ;https://www.good-display.com/product/439.html -DEINK_DISPLAY_MODEL=GxEPD2_579_GDEY0579T93 ;https://www.good-display.com/product/439.html
-DEINK_WIDTH=792 -DEINK_WIDTH=792
-DEINK_HEIGHT=272 -DEINK_HEIGHT=272
@@ -46,7 +45,6 @@ build_flags =
-I variants/esp32s3/crowpanel-esp32s3-5-epaper -I variants/esp32s3/crowpanel-esp32s3-5-epaper
-D PRIVATE_HW -D PRIVATE_HW
-DBOARD_HAS_PSRAM -DBOARD_HAS_PSRAM
-DGPS_POWER_TOGGLE
-DEINK_DISPLAY_MODEL=GxEPD2_420_GYE042A87 ; similar Panel: GDEY042T81 : https://www.good-display.com/product/386.html -DEINK_DISPLAY_MODEL=GxEPD2_420_GYE042A87 ; similar Panel: GDEY042T81 : https://www.good-display.com/product/386.html
-DEINK_WIDTH=400 -DEINK_WIDTH=400
-DEINK_HEIGHT=300 -DEINK_HEIGHT=300
@@ -76,7 +74,6 @@ build_flags =
-I variants/esp32s3/crowpanel-esp32s3-5-epaper -I variants/esp32s3/crowpanel-esp32s3-5-epaper
-D PRIVATE_HW -D PRIVATE_HW
-DBOARD_HAS_PSRAM -DBOARD_HAS_PSRAM
-DGPS_POWER_TOGGLE
-DEINK_DISPLAY_MODEL=GxEPD2_290_GDEY029T94 ;https://www.good-display.com/product/389.html -DEINK_DISPLAY_MODEL=GxEPD2_290_GDEY029T94 ;https://www.good-display.com/product/389.html
-DEINK_WIDTH=296 -DEINK_WIDTH=296
-DEINK_HEIGHT=128 -DEINK_HEIGHT=128
@@ -6,5 +6,4 @@ board_build.partitions = default_8MB.csv
build_flags = build_flags =
${esp32s3_base.build_flags} -I variants/esp32s3/heltec_capsule_sensor_v3 ${esp32s3_base.build_flags} -I variants/esp32s3/heltec_capsule_sensor_v3
-D HELTEC_CAPSULE_SENSOR_V3 -D HELTEC_CAPSULE_SENSOR_V3
-D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely.
;-D DEBUG_DISABLED ; uncomment this line to disable DEBUG output ;-D DEBUG_DISABLED ; uncomment this line to disable DEBUG output
@@ -8,4 +8,3 @@ build_flags =
${esp32s3_base.build_flags} ${esp32s3_base.build_flags}
-D HELTEC_V3 -D HELTEC_V3
-I variants/esp32s3/heltec_v3 -I variants/esp32s3/heltec_v3
-D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely.
@@ -7,4 +7,3 @@ build_flags =
${esp32s3_base.build_flags} ${esp32s3_base.build_flags}
-D HELTEC_V4 -D HELTEC_V4
-I variants/esp32s3/heltec_v4 -I variants/esp32s3/heltec_v4
-D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely.
@@ -8,7 +8,6 @@ build_flags =
${esp32s3_base.build_flags} ${esp32s3_base.build_flags}
-I variants/esp32s3/heltec_wireless_tracker -I variants/esp32s3/heltec_wireless_tracker
-D HELTEC_TRACKER_V1_1 -D HELTEC_TRACKER_V1_1
-D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely.
;-D DEBUG_DISABLED ; uncomment this line to disable DEBUG output ;-D DEBUG_DISABLED ; uncomment this line to disable DEBUG output
lib_deps = lib_deps =
@@ -8,7 +8,6 @@ build_flags =
${esp32s3_base.build_flags} ${esp32s3_base.build_flags}
-I variants/esp32s3/heltec_wireless_tracker_V1_0 -I variants/esp32s3/heltec_wireless_tracker_V1_0
-D HELTEC_TRACKER_V1_0 -D HELTEC_TRACKER_V1_0
-D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely.
;-D DEBUG_DISABLED ; uncomment this line to disable DEBUG output ;-D DEBUG_DISABLED ; uncomment this line to disable DEBUG output
lib_deps = lib_deps =
${esp32s3_base.lib_deps} ${esp32s3_base.lib_deps}
@@ -8,7 +8,6 @@ build_flags =
${esp32s3_base.build_flags} ${esp32s3_base.build_flags}
-I variants/esp32s3/heltec_wireless_tracker_v2 -I variants/esp32s3/heltec_wireless_tracker_v2
-D HELTEC_WIRELESS_TRACKER_V2 -D HELTEC_WIRELESS_TRACKER_V2
-D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely.
lib_deps = lib_deps =
${esp32s3_base.lib_deps} ${esp32s3_base.lib_deps}
lovyan03/LovyanGFX@^1.2.0 lovyan03/LovyanGFX@^1.2.0
@@ -7,4 +7,3 @@ build_flags =
${esp32s3_base.build_flags} ${esp32s3_base.build_flags}
-D HELTEC_WSL_V3 -D HELTEC_WSL_V3
-I variants/esp32s3/heltec_wsl_v3 -I variants/esp32s3/heltec_wsl_v3
-D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely.
@@ -5,7 +5,6 @@ build_flags =
${esp32_base.build_flags} ${esp32_base.build_flags}
-D LINK_32 -D LINK_32
-I variants/esp32s3/link32_s3_v1 -I variants/esp32s3/link32_s3_v1
-DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely.
-DARDUINO_USB_CDC_ON_BOOT -DARDUINO_USB_CDC_ON_BOOT
-DARDUINO_USB_MODE=1 -DARDUINO_USB_MODE=1
-DRADIOLIB_EXCLUDE_SX128X=1 -DRADIOLIB_EXCLUDE_SX128X=1
@@ -7,7 +7,6 @@ upload_protocol = esptool
build_flags = build_flags =
${esp32_base.build_flags} -I variants/esp32s3/t-deck-pro ${esp32_base.build_flags} -I variants/esp32s3/t-deck-pro
-D T_DECK_PRO -D T_DECK_PRO
-D GPS_POWER_TOGGLE
-D USE_EINK -D USE_EINK
-D EINK_DISPLAY_MODEL=GxEPD2_310_GDEQ031T10 -D EINK_DISPLAY_MODEL=GxEPD2_310_GDEQ031T10
-D EINK_WIDTH=240 -D EINK_WIDTH=240
-1
View File
@@ -9,7 +9,6 @@ upload_protocol = esptool
build_flags = ${esp32s3_base.build_flags} build_flags = ${esp32s3_base.build_flags}
-D T_DECK -D T_DECK
-D BOARD_HAS_PSRAM -D BOARD_HAS_PSRAM
-D GPS_POWER_TOGGLE
-I variants/esp32s3/t-deck -I variants/esp32s3/t-deck
lib_deps = ${esp32s3_base.lib_deps} lib_deps = ${esp32s3_base.lib_deps}
@@ -9,7 +9,6 @@ build_flags =
-D T_ETH_ELITE -D T_ETH_ELITE
-D HAS_UDP_MULTICAST=1 -D HAS_UDP_MULTICAST=1
-I variants/esp32s3/t-eth-elite -I variants/esp32s3/t-eth-elite
-D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely.
lib_ignore = lib_ignore =
Ethernet Ethernet
@@ -10,7 +10,6 @@ build_flags = ${esp32s3_base.build_flags}
-I variants/esp32s3/tlora-pager -I variants/esp32s3/tlora-pager
-D T_LORA_PAGER -D T_LORA_PAGER
-D BOARD_HAS_PSRAM -D BOARD_HAS_PSRAM
-D GPS_POWER_TOGGLE
-D HAS_SDCARD -D HAS_SDCARD
-D SDCARD_USE_SPI1 -D SDCARD_USE_SPI1
-D ENABLE_ROTARY_PULLUP -D ENABLE_ROTARY_PULLUP

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