diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 1953619c8..dbbd0e52e 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -33,7 +33,7 @@ jobs: - board: m5stack-coreink - board: tbeam-s3-core - board: tlora-t3s3-v1 - + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -41,6 +41,9 @@ jobs: id: base uses: ./.github/actions/setup-base + - name: Trunk Check + uses: trunk-io/trunk-action@v1 + - name: Check ${{ matrix.board }} run: bin/check-all.sh ${{ matrix.board }} @@ -109,14 +112,14 @@ jobs: uses: ./.github/actions/setup-base # We now run integration test before other build steps (to quickly see runtime failures) - - name: Build for native - run: platformio run -e native - - name: Integration test - run: | - .pio/build/native/program & - sleep 20 # 5 seconds was not enough - echo "Simulator started, launching python test..." - python3 -c 'from meshtastic.test import testSimulator; testSimulator()' + #- name: Build for native + # run: platformio run -e native + #- name: Integration test + # run: | + #.pio/build/native/program + #& sleep 20 # 5 seconds was not enough + #echo "Simulator started, launching python test..." + #python3 -c 'from meshtastic.test import testSimulator; testSimulator()' - name: Build Native run: bin/build-native.sh @@ -132,11 +135,11 @@ jobs: path: | release/device-*.sh release/device-*.bat - + - name: Docker login if: ${{ github.event_name == 'workflow_dispatch' }} uses: docker/login-action@v2 - with: + with: username: meshtastic password: ${{ secrets.DOCKER_TOKEN }} @@ -152,7 +155,7 @@ jobs: file: ./Dockerfile push: true tags: meshtastic/device-simulator:latest - + after-checks: runs-on: ubuntu-latest needs: [check] diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 000000000..d9d52a2a4 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,19 @@ +name: Nightly +on: + schedule: + - cron: 0 8 * * 1-5 + workflow_dispatch: {} + +jobs: + trunk_check: + name: Trunk Check Upload + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Trunk Check + uses: trunk-io/trunk-action@v1 + with: + trunk-token: ${{ secrets.TRUNK_TOKEN }} diff --git a/.trunk/.gitignore b/.trunk/.gitignore new file mode 100644 index 000000000..cf2f25470 --- /dev/null +++ b/.trunk/.gitignore @@ -0,0 +1,7 @@ +*out +*logs +*actions +*notifications +plugins +user_trunk.yaml +user.yaml diff --git a/.clang-format b/.trunk/configs/.clang-format similarity index 100% rename from .clang-format rename to .trunk/configs/.clang-format diff --git a/.trunk/configs/.hadolint.yaml b/.trunk/configs/.hadolint.yaml new file mode 100644 index 000000000..98bf0cd2e --- /dev/null +++ b/.trunk/configs/.hadolint.yaml @@ -0,0 +1,4 @@ +# Following source doesn't work in most setups +ignored: + - SC1090 + - SC1091 diff --git a/.trunk/configs/.markdownlint.yaml b/.trunk/configs/.markdownlint.yaml new file mode 100644 index 000000000..fb940393d --- /dev/null +++ b/.trunk/configs/.markdownlint.yaml @@ -0,0 +1,10 @@ +# Autoformatter friendly markdownlint config (all formatting rules disabled) +default: true +blank_lines: false +bullet: false +html: false +indentation: false +line_length: false +spaces: false +url: false +whitespace: false diff --git a/.trunk/configs/.shellcheckrc b/.trunk/configs/.shellcheckrc new file mode 100644 index 000000000..8c7b1ada8 --- /dev/null +++ b/.trunk/configs/.shellcheckrc @@ -0,0 +1,7 @@ +enable=all +source-path=SCRIPTDIR +disable=SC2154 + +# If you're having issues with shellcheck following source, disable the errors via: +# disable=SC1090 +# disable=SC1091 diff --git a/.trunk/configs/svgo.config.js b/.trunk/configs/svgo.config.js new file mode 100644 index 000000000..b257d1349 --- /dev/null +++ b/.trunk/configs/svgo.config.js @@ -0,0 +1,14 @@ +module.exports = { + plugins: [ + { + name: "preset-default", + params: { + overrides: { + removeViewBox: false, // https://github.com/svg/svgo/issues/1128 + sortAttrs: true, + removeOffCanvasPaths: true, + }, + }, + }, + ], +}; diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml new file mode 100644 index 000000000..3ba9cca33 --- /dev/null +++ b/.trunk/trunk.yaml @@ -0,0 +1,32 @@ +version: 0.1 +cli: + version: 1.3.1 +plugins: + sources: + - id: trunk + ref: v0.0.8 + uri: https://github.com/trunk-io/plugins +lint: + enabled: + - shellcheck@0.9.0 + - shfmt@3.5.0 + - oxipng@8.0.0 + - actionlint@1.6.22 + - git-diff-check + - gitleaks@8.15.2 + - markdownlint@0.33.0 + - hadolint@2.12.0 + - clang-format@14.0.0 + - prettier@2.8.3 + - svgo@3.0.2 +runtimes: + enabled: + - go@1.18.3 + - node@18.12.1 +actions: + disabled: + - trunk-announce + - trunk-check-pre-push + - trunk-fmt-pre-commit + enabled: + - trunk-upgrade-available diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 9a91518aa..4fc84fa78 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -2,10 +2,8 @@ // See http://go.microsoft.com/fwlink/?LinkId=827846 // for the documentation about the extensions.json format "recommendations": [ + "ms-vscode.cpptools", "platformio.platformio-ide", - "xaver.clang-format" + "trunk.io" ], - "unwantedRecommendations": [ - "ms-vscode.cpptools-extension-pack" - ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 21b7b97b7..3b489975b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,80 +1,4 @@ { - "files.associations": { - "type_traits": "cpp", - "array": "cpp", - "*.tcc": "cpp", - "cctype": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "deque": "cpp", - "unordered_map": "cpp", - "unordered_set": "cpp", - "vector": "cpp", - "exception": "cpp", - "algorithm": "cpp", - "functional": "cpp", - "system_error": "cpp", - "tuple": "cpp", - "fstream": "cpp", - "initializer_list": "cpp", - "iomanip": "cpp", - "iosfwd": "cpp", - "istream": "cpp", - "limits": "cpp", - "memory": "cpp", - "new": "cpp", - "ostream": "cpp", - "numeric": "cpp", - "sstream": "cpp", - "stdexcept": "cpp", - "streambuf": "cpp", - "cinttypes": "cpp", - "utility": "cpp", - "typeinfo": "cpp", - "string": "cpp", - "*.xbm": "cpp", - "list": "cpp", - "atomic": "cpp", - "memory_resource": "cpp", - "optional": "cpp", - "string_view": "cpp", - "cassert": "cpp", - "iterator": "cpp", - "shared_mutex": "cpp", - "iostream": "cpp", - "esp_nimble_hci.h": "c", - "map": "cpp", - "random": "cpp", - "*.tpp": "cpp" - }, - "cSpell.words": [ - "Blox", - "EINK", - "HFSR", - "Meshtastic", - "NEMAGPS", - "NMEAGPS", - "RDEF", - "Ublox", - "bkpt", - "cfsr", - "descs", - "ocrypto", - "protobufs", - "wifi" - ], - "C_Cpp.dimInactiveRegions": true, - "cmake.configureOnOpen": true, - "protoc": { - "compile_on_save": false, - } -} \ No newline at end of file + "editor.formatOnSave": true, + "editor.defaultFormatter": "trunk.io" +} diff --git a/bin/regen-protos.bat b/bin/regen-protos.bat index 5c576c5b2..29f35d0ae 100644 --- a/bin/regen-protos.bat +++ b/bin/regen-protos.bat @@ -1 +1 @@ -cd protobufs && ..\nanopb-0.4.7\generator-bin\protoc.exe --nanopb_out=-v:..\src\mesh\generated -I=..\protobufs *.proto +cd protobufs && ..\nanopb-0.4.7\generator-bin\protoc.exe --nanopb_out=-v:..\src\mesh\generated\meshtastic -I=..\protobufs meshtastic\*.proto diff --git a/bin/regen-protos.sh b/bin/regen-protos.sh index 133d587a3..abfe7a141 100755 --- a/bin/regen-protos.sh +++ b/bin/regen-protos.sh @@ -8,7 +8,12 @@ echo "prebuilt binaries for your computer into nanopb-0.4.7" # the nanopb tool seems to require that the .options file be in the current directory! cd protobufs -../nanopb-0.4.7/generator-bin/protoc --nanopb_out=-v:../src/mesh/generated -I=../protobufs *.proto +../nanopb-0.4.7/generator-bin/protoc --nanopb_out=-v:../src/mesh/generated/ -I=../protobufs meshtastic/*.proto + +cd ../src/mesh/generated/meshtastic +sed -i 's/#include "meshtastic/#include "./g' * + +sed -i 's/meshtastic_//g' * #echo "Regenerating protobuf documentation - if you see an error message" #echo "you can ignore it unless doing a new protobuf release to github." diff --git a/protobufs b/protobufs index 1763fe4a3..aaa6e08b2 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 1763fe4a389f0864f153a9986699e1ea56e67fac +Subproject commit aaa6e08b2e00127d4396f3a994cede4a749cff9c diff --git a/src/detect/i2cScan.h b/src/detect/i2cScan.h index 77d1fff17..0189677bd 100644 --- a/src/detect/i2cScan.h +++ b/src/detect/i2cScan.h @@ -1,11 +1,11 @@ #include "../configuration.h" #include "../main.h" +#include "mesh/generated/meshtastic/telemetry.pb.h" #include -#include "mesh/generated/telemetry.pb.h" // AXP192 and AXP2101 have the same device address, we just need to identify it in Power.cpp #ifndef XPOWERS_AXP192_AXP2101_ADDRESS -#define XPOWERS_AXP192_AXP2101_ADDRESS 0x34 +#define XPOWERS_AXP192_AXP2101_ADDRESS 0x34 #endif #if HAS_WIRE @@ -16,27 +16,27 @@ void printATECCInfo() atecc.readConfigZone(false); LOG_DEBUG("ATECC608B Serial Number: "); - for (int i = 0 ; i < 9 ; i++) { - LOG_DEBUG("%02x",atecc.serialNumber[i]); + for (int i = 0; i < 9; i++) { + LOG_DEBUG("%02x", atecc.serialNumber[i]); } LOG_DEBUG(", Rev Number: "); - for (int i = 0 ; i < 4 ; i++) { - LOG_DEBUG("%02x",atecc.revisionNumber[i]); + for (int i = 0; i < 4; i++) { + LOG_DEBUG("%02x", atecc.revisionNumber[i]); } LOG_DEBUG("\n"); - LOG_DEBUG("ATECC608B Config %s",atecc.configLockStatus ? "Locked" : "Unlocked"); - LOG_DEBUG(", Data %s",atecc.dataOTPLockStatus ? "Locked" : "Unlocked"); - LOG_DEBUG(", Slot 0 %s\n",atecc.slot0LockStatus ? "Locked" : "Unlocked"); + LOG_DEBUG("ATECC608B Config %s", atecc.configLockStatus ? "Locked" : "Unlocked"); + LOG_DEBUG(", Data %s", atecc.dataOTPLockStatus ? "Locked" : "Unlocked"); + LOG_DEBUG(", Slot 0 %s\n", atecc.slot0LockStatus ? "Locked" : "Unlocked"); if (atecc.configLockStatus && atecc.dataOTPLockStatus && atecc.slot0LockStatus) { if (atecc.generatePublicKey() == false) { LOG_DEBUG("ATECC608B Error generating public key\n"); } else { LOG_DEBUG("ATECC608B Public Key: "); - for (int i = 0 ; i < 64 ; i++) { - LOG_DEBUG("%02x",atecc.publicKey64Bytes[i]); + for (int i = 0; i < 64; i++) { + LOG_DEBUG("%02x", atecc.publicKey64Bytes[i]); } LOG_DEBUG("\n"); } @@ -44,7 +44,8 @@ void printATECCInfo() #endif } -uint16_t getRegisterValue(uint8_t address, uint8_t reg, uint8_t length) { +uint16_t getRegisterValue(uint8_t address, uint8_t reg, uint8_t length) +{ uint16_t value = 0x00; Wire.beginTransmission(address); Wire.write(reg); @@ -54,7 +55,7 @@ uint16_t getRegisterValue(uint8_t address, uint8_t reg, uint8_t length) { LOG_DEBUG("Wire.available() = %d\n", Wire.available()); if (Wire.available() == 2) { // Read MSB, then LSB - value = (uint16_t)Wire.read() << 8; + value = (uint16_t)Wire.read() << 8; value |= Wire.read(); } else if (Wire.available()) { value = Wire.read(); @@ -81,7 +82,7 @@ uint8_t oled_probe(byte addr) if (r == 0x08 || r == 0x00) { o_probe = 2; // SH1106 - } else if ( r == 0x03 || r == 0x04 || r == 0x06 || r == 0x07) { + } else if (r == 0x03 || r == 0x04 || r == 0x06 || r == 0x07) { o_probe = 1; // SSD1306 } c++; @@ -126,17 +127,17 @@ void scanI2Cdevice() } #endif #ifdef RV3028_RTC - if (addr == RV3028_RTC){ + if (addr == RV3028_RTC) { rtc_found = addr; LOG_INFO("RV3028 RTC found\n"); Melopero_RV3028 rtc; rtc.initI2C(); - rtc.writeToRegister(0x35,0x07); // no Clkout - rtc.writeToRegister(0x37,0xB4); + rtc.writeToRegister(0x35, 0x07); // no Clkout + rtc.writeToRegister(0x37, 0xB4); } #endif #ifdef PCF8563_RTC - if (addr == PCF8563_RTC){ + if (addr == PCF8563_RTC) { rtc_found = addr; LOG_INFO("PCF8563 RTC found\n"); } @@ -225,7 +226,7 @@ void scanI2Cdevice() if (nDevices == 0) LOG_INFO("No I2C devices found\n"); else - LOG_INFO("%i I2C devices found\n",nDevices); + LOG_INFO("%i I2C devices found\n", nDevices); } #else void scanI2Cdevice() {} diff --git a/src/error.h b/src/error.h index e57407bf8..087215b1d 100644 --- a/src/error.h +++ b/src/error.h @@ -2,10 +2,11 @@ #include -#include "mesh/generated/mesh.pb.h" // For CriticalErrorCode +#include "mesh/generated/meshtastic/mesh.pb.h" // For CriticalErrorCode /// A macro that include filename and line #define RECORD_CRITICALERROR(code) recordCriticalError(code, __LINE__, __FILE__) /// Record an error that should be reported via analytics -void recordCriticalError(CriticalErrorCode code = CriticalErrorCode_UNSPECIFIED, uint32_t address = 0, const char *filename = NULL); +void recordCriticalError(CriticalErrorCode code = CriticalErrorCode_UNSPECIFIED, uint32_t address = 0, + const char *filename = NULL); diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 034ba3307..abaeec660 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -33,9 +33,9 @@ along with this program. If not, see . #include "main.h" #include "mesh-pb-constants.h" #include "mesh/Channels.h" -#include "mesh/generated/deviceonly.pb.h" -#include "modules/TextMessageModule.h" +#include "mesh/generated/meshtastic/deviceonly.pb.h" #include "modules/ExternalNotificationModule.h" +#include "modules/TextMessageModule.h" #include "sleep.h" #include "target_specific.h" #include "utils.h" @@ -69,7 +69,7 @@ static uint32_t targetFramerate = IDLE_FRAMERATE; static char btPIN[16] = "888888"; uint32_t logo_timeout = 5000; // 4 seconds for EACH logo - + // This image definition is here instead of images.h because it's modified dynamically by the drawBattery function uint8_t imgBattery[16] = {0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xE7, 0x3C}; @@ -97,9 +97,9 @@ static uint16_t displayWidth, displayHeight; #if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) // The screen is bigger so use bigger fonts -#define FONT_SMALL ArialMT_Plain_16 // Height: 19 +#define FONT_SMALL ArialMT_Plain_16 // Height: 19 #define FONT_MEDIUM ArialMT_Plain_24 // Height: 28 -#define FONT_LARGE ArialMT_Plain_24 // Height: 28 +#define FONT_LARGE ArialMT_Plain_24 // Height: 28 #else #ifdef OLED_RU #define FONT_SMALL ArialMT_Plain_10_RU @@ -107,7 +107,7 @@ static uint16_t displayWidth, displayHeight; #define FONT_SMALL ArialMT_Plain_10 // Height: 13 #endif #define FONT_MEDIUM ArialMT_Plain_16 // Height: 19 -#define FONT_LARGE ArialMT_Plain_24 // Height: 28 +#define FONT_LARGE ArialMT_Plain_24 // Height: 28 #endif #define fontHeight(font) ((font)[1] + 1) // height is position 1 @@ -118,7 +118,6 @@ static uint16_t displayWidth, displayHeight; #define getStringCenteredX(s) ((SCREEN_WIDTH - display->getStringWidth(s)) / 2) - /** * Draw the icon with extra info printed around the corners */ @@ -236,7 +235,7 @@ static void drawWelcomeScreen(OLEDDisplay *display, OLEDDisplayUiState *state, i display->drawString(64 + x, y, "//\\ E S H T /\\ S T / C"); display->drawString(64 + x, y + FONT_HEIGHT_SMALL, getDeviceName()); display->setTextAlignment(TEXT_ALIGN_LEFT); - + if ((millis() / 10000) % 2) { display->drawString(x, y + FONT_HEIGHT_SMALL * 2 - 3, "Set the region using the"); display->drawString(x, y + FONT_HEIGHT_SMALL * 3 - 3, "Meshtastic Android, iOS,"); @@ -292,7 +291,7 @@ static void drawFrameBluetooth(OLEDDisplay *display, OLEDDisplayUiState *state, display->drawString(x_offset + x, y_offset + y, "Bluetooth"); display->setFont(FONT_SMALL); - y_offset = display->height() == 64 ? y_offset + FONT_HEIGHT_MEDIUM -4 : y_offset + FONT_HEIGHT_MEDIUM + 5; + y_offset = display->height() == 64 ? y_offset + FONT_HEIGHT_MEDIUM - 4 : y_offset + FONT_HEIGHT_MEDIUM + 5; display->drawString(x_offset + x, y_offset + y, "Enter this code"); display->setFont(FONT_LARGE); @@ -302,7 +301,7 @@ static void drawFrameBluetooth(OLEDDisplay *display, OLEDDisplayUiState *state, display->drawString(x_offset + x, y_offset + y, pin); display->setFont(FONT_SMALL); - String deviceName = "Name: "; + String deviceName = "Name: "; deviceName.concat(getDeviceName()); y_offset = display->height() == 64 ? y_offset + FONT_HEIGHT_LARGE - 6 : y_offset + FONT_HEIGHT_LARGE + 5; display->drawString(x_offset + x, y_offset + y, deviceName); @@ -332,7 +331,8 @@ static void drawFrameFirmware(OLEDDisplay *display, OLEDDisplayUiState *state, i display->setFont(FONT_SMALL); display->setTextAlignment(TEXT_ALIGN_LEFT); - display->drawStringMaxWidth(0 + x, 2 + y + FONT_HEIGHT_SMALL *2, x + display->getWidth(), "Please be patient and do not power off."); + display->drawStringMaxWidth(0 + x, 2 + y + FONT_HEIGHT_SMALL * 2, x + display->getWidth(), + "Please be patient and do not power off."); } /// Draw the last text message we received @@ -354,8 +354,7 @@ static void drawCriticalFaultFrame(OLEDDisplay *display, OLEDDisplayUiState *sta // Ignore messages orginating from phone (from the current node 0x0) unless range test or store and forward module are enabled static bool shouldDrawMessage(const MeshPacket *packet) { - return packet->from != 0 && !moduleConfig.range_test.enabled && - !moduleConfig.store_forward.enabled; + return packet->from != 0 && !moduleConfig.range_test.enabled && !moduleConfig.store_forward.enabled; } /// Draw the last text message we received @@ -381,7 +380,7 @@ static void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state display->setColor(BLACK); } display->drawStringf(0 + x, 0 + y, tempBuf, "From: %s", (node && node->has_user) ? node->user.short_name : "???"); - if(config.display.heading_bold) { + if (config.display.heading_bold) { display->drawStringf(1 + x, 0 + y, tempBuf, "From: %s", (node && node->has_user) ? node->user.short_name : "???"); } display->setColor(WHITE); @@ -477,7 +476,7 @@ static void drawNodes(OLEDDisplay *display, int16_t x, int16_t y, NodeStatus *no display->drawFastImage(x, y, 8, 8, imgUser); #endif display->drawString(x + 10, y - 2, usersString); - if(config.display.heading_bold) + if (config.display.heading_bold) display->drawString(x + 11, y - 2, usersString); } @@ -487,20 +486,20 @@ static void drawGPS(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus if (config.position.fixed_position) { // GPS coordinates are currently fixed display->drawString(x - 1, y - 2, "Fixed GPS"); - if(config.display.heading_bold) + if (config.display.heading_bold) display->drawString(x, y - 2, "Fixed GPS"); return; } if (!gps->getIsConnected()) { display->drawString(x, y - 2, "No GPS"); - if(config.display.heading_bold) + if (config.display.heading_bold) display->drawString(x + 1, y - 2, "No GPS"); return; } display->drawFastImage(x, y, 6, 8, gps->getHasLock() ? imgPositionSolid : imgPositionEmpty); if (!gps->getHasLock()) { display->drawString(x + 8, y - 2, "No sats"); - if(config.display.heading_bold) + if (config.display.heading_bold) display->drawString(x + 9, y - 2, "No sats"); return; } else { @@ -523,24 +522,24 @@ static void drawGPS(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus // Draw the number of satellites snprintf(satsString, sizeof(satsString), "%u", gps->getNumSatellites()); display->drawString(x + 34, y - 2, satsString); - if(config.display.heading_bold) + if (config.display.heading_bold) display->drawString(x + 35, y - 2, satsString); } } -//Draw status when gps is disabled by PMU +// Draw status when gps is disabled by PMU static void drawGPSpowerstat(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus *gps) { -#ifdef HAS_PMU +#ifdef HAS_PMU String displayLine = "GPS disabled"; int16_t xPos = display->getStringWidth(displayLine); - if (!config.position.gps_enabled){ + if (!config.position.gps_enabled) { display->drawString(x + xPos, y, displayLine); -#ifdef GPS_POWER_TOGGLE +#ifdef GPS_POWER_TOGGLE display->drawString(x + xPos, y - 2 + FONT_HEIGHT_SMALL, " by button"); #endif - //display->drawString(x + xPos, y + 2, displayLine); + // display->drawString(x + xPos, y + 2, displayLine); } #endif } @@ -582,22 +581,23 @@ static void drawGPScoordinates(OLEDDisplay *display, int16_t x, int16_t y, const if (gpsFormat != Config_DisplayConfig_GpsCoordinateFormat_DMS) { char coordinateLine[22]; if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_DEC) { // Decimal Degrees - snprintf(coordinateLine, sizeof(coordinateLine), "%f %f", geoCoord.getLatitude() * 1e-7, geoCoord.getLongitude() * 1e-7); + snprintf(coordinateLine, sizeof(coordinateLine), "%f %f", geoCoord.getLatitude() * 1e-7, + geoCoord.getLongitude() * 1e-7); } else if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_UTM) { // Universal Transverse Mercator snprintf(coordinateLine, sizeof(coordinateLine), "%2i%1c %06u %07u", geoCoord.getUTMZone(), geoCoord.getUTMBand(), - geoCoord.getUTMEasting(), geoCoord.getUTMNorthing()); + geoCoord.getUTMEasting(), geoCoord.getUTMNorthing()); } else if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_MGRS) { // Military Grid Reference System - snprintf(coordinateLine, sizeof(coordinateLine), "%2i%1c %1c%1c %05u %05u", geoCoord.getMGRSZone(), geoCoord.getMGRSBand(), - geoCoord.getMGRSEast100k(), geoCoord.getMGRSNorth100k(), geoCoord.getMGRSEasting(), - geoCoord.getMGRSNorthing()); + snprintf(coordinateLine, sizeof(coordinateLine), "%2i%1c %1c%1c %05u %05u", geoCoord.getMGRSZone(), + geoCoord.getMGRSBand(), geoCoord.getMGRSEast100k(), geoCoord.getMGRSNorth100k(), + geoCoord.getMGRSEasting(), geoCoord.getMGRSNorthing()); } else if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_OLC) { // Open Location Code geoCoord.getOLCCode(coordinateLine); - } else if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_OSGR) { // Ordnance Survey Grid Reference + } else if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_OSGR) { // Ordnance Survey Grid Reference if (geoCoord.getOSGRE100k() == 'I' || geoCoord.getOSGRN100k() == 'I') // OSGR is only valid around the UK region snprintf(coordinateLine, sizeof(coordinateLine), "%s", "Out of Boundary"); else - snprintf(coordinateLine, sizeof(coordinateLine), "%1c%1c %05u %05u", geoCoord.getOSGRE100k(), geoCoord.getOSGRN100k(), - geoCoord.getOSGREasting(), geoCoord.getOSGRNorthing()); + snprintf(coordinateLine, sizeof(coordinateLine), "%1c%1c %05u %05u", geoCoord.getOSGRE100k(), + geoCoord.getOSGRN100k(), geoCoord.getOSGREasting(), geoCoord.getOSGRNorthing()); } // If fixed position, display text "Fixed GPS" alternating with the coordinates. @@ -614,10 +614,10 @@ static void drawGPScoordinates(OLEDDisplay *display, int16_t x, int16_t y, const } else { char latLine[22]; char lonLine[22]; - snprintf(latLine, sizeof(latLine), "%2i° %2i' %2u\" %1c", geoCoord.getDMSLatDeg(), geoCoord.getDMSLatMin(), geoCoord.getDMSLatSec(), - geoCoord.getDMSLatCP()); - snprintf(lonLine, sizeof(lonLine), "%3i° %2i' %2u\" %1c", geoCoord.getDMSLonDeg(), geoCoord.getDMSLonMin(), geoCoord.getDMSLonSec(), - geoCoord.getDMSLonCP()); + snprintf(latLine, sizeof(latLine), "%2i° %2i' %2u\" %1c", geoCoord.getDMSLatDeg(), geoCoord.getDMSLatMin(), + geoCoord.getDMSLatSec(), geoCoord.getDMSLatCP()); + snprintf(lonLine, sizeof(lonLine), "%3i° %2i' %2u\" %1c", geoCoord.getDMSLonDeg(), geoCoord.getDMSLonMin(), + geoCoord.getDMSLonSec(), geoCoord.getDMSLonCP()); display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(latLine))) / 2, y - FONT_HEIGHT_SMALL * 1, latLine); display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(lonLine))) / 2, y, lonLine); } @@ -653,8 +653,8 @@ class Point void scale(float f) { - //We use -f here to counter the flip that happens - //on the y axis when drawing and rotating on screen + // We use -f here to counter the flip that happens + // on the y axis when drawing and rotating on screen x *= f; y *= -f; } @@ -713,7 +713,7 @@ static uint16_t getCompassDiam(OLEDDisplay *display) offset = FONT_HEIGHT_SMALL; // get the smaller of the 2 dimensions and subtract 20 - if(display->getWidth() > (display->getHeight() - offset)) { + if (display->getWidth() > (display->getHeight() - offset)) { diam = display->getHeight() - offset; // if 2/3 of the other size would be smaller, use that if (diam > (display->getWidth() * 2 / 3)) { @@ -725,7 +725,7 @@ static uint16_t getCompassDiam(OLEDDisplay *display) diam = (display->getHeight() - offset) * 2 / 3; } } - + return diam - 20; }; @@ -756,10 +756,10 @@ static void drawNodeHeading(OLEDDisplay *display, int16_t compassX, int16_t comp // Draw north static void drawCompassNorth(OLEDDisplay *display, int16_t compassX, int16_t compassY, float myHeading) { - //If north is supposed to be at the top of the compass we want rotation to be +0 - if(config.display.compass_north_top) + // If north is supposed to be at the top of the compass we want rotation to be +0 + if (config.display.compass_north_top) myHeading = -0; - + Point N1(-0.04f, 0.65f), N2(0.04f, 0.65f); Point N3(-0.04f, 0.55f), N4(0.04f, 0.55f); Point *rosePoints[] = {&N1, &N2, &N3, &N4}; @@ -874,7 +874,7 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_ GeoCoord::bearing(DegD(op.latitude_i), DegD(op.longitude_i), DegD(p.latitude_i), DegD(p.longitude_i)); // If the top of the compass is a static north then bearingToOther can be drawn on the compass directly // If the top of the compass is not a static north we need adjust bearingToOther based on heading - if(!config.display.compass_north_top) + if (!config.display.compass_north_top) bearingToOther -= myHeading; drawNodeHeading(display, compassX, compassY, bearingToOther); } @@ -1000,8 +1000,8 @@ void Screen::setup() #ifdef SCREEN_MIRROR dispdev.mirrorScreen(); #else - // Standard behaviour is to FLIP the screen (needed on T-Beam). If this config item is set, unflip it, and thereby logically flip it. - // If you have a headache now, you're welcome. + // Standard behaviour is to FLIP the screen (needed on T-Beam). If this config item is set, unflip it, and thereby logically + // flip it. If you have a headache now, you're welcome. if (!config.display.flip_screen) { dispdev.flipScreenVertically(); } @@ -1071,7 +1071,7 @@ int32_t Screen::runOnce() static const int bootOEMFrameCount = sizeof(bootOEMFrames) / sizeof(bootOEMFrames[0]); ui.setFrames(bootOEMFrames, bootOEMFrameCount); ui.update(); -#ifndef USE_EINK +#ifndef USE_EINK ui.update(); #endif showingOEMBootScreen = false; @@ -1414,7 +1414,7 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16 // Display power status if (powerStatus->getHasBattery()) { if (config.display.displaymode == Config_DisplayConfig_DisplayMode_DEFAULT) { - drawBattery(display, x , y + 2, imgBattery, powerStatus); + drawBattery(display, x, y + 2, imgBattery, powerStatus); } else { drawBattery(display, x + 1, y + 3, imgBattery, powerStatus); } @@ -1432,7 +1432,7 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16 drawNodes(display, x + (SCREEN_WIDTH * 0.25), y + 3, nodeStatus); } // Display GPS status - if (!config.position.gps_enabled){ + if (!config.position.gps_enabled) { int16_t yPos = y + 2; #ifdef GPS_POWER_TOGGLE yPos = (y + 10 + FONT_HEIGHT_SMALL); @@ -1451,27 +1451,36 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16 display->drawString(x, y + FONT_HEIGHT_SMALL, channelStr); // Draw our hardware ID to assist with bluetooth pairing. Either prefix with Info or S&F Logo if (moduleConfig.store_forward.enabled) { -#ifdef ARCH_ESP32 - if (millis() - storeForwardModule->lastHeartbeat > (storeForwardModule->heartbeatInterval * 1200)) { //no heartbeat, overlap a bit +#ifdef ARCH_ESP32 + if (millis() - storeForwardModule->lastHeartbeat > + (storeForwardModule->heartbeatInterval * 1200)) { // no heartbeat, overlap a bit #if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) - display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 3 + FONT_HEIGHT_SMALL, 12, 8, imgQuestionL1); - display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 11 + FONT_HEIGHT_SMALL, 12, 8, imgQuestionL2); + display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 3 + FONT_HEIGHT_SMALL, 12, 8, + imgQuestionL1); + display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 11 + FONT_HEIGHT_SMALL, 12, 8, + imgQuestionL2); #else - display->drawFastImage(x + SCREEN_WIDTH - 10 - display->getStringWidth(ourId), y + 2 + FONT_HEIGHT_SMALL, 8, 8, imgQuestion); + display->drawFastImage(x + SCREEN_WIDTH - 10 - display->getStringWidth(ourId), y + 2 + FONT_HEIGHT_SMALL, 8, 8, + imgQuestion); #endif } else { #if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) - display->drawFastImage(x + SCREEN_WIDTH - 18 - display->getStringWidth(ourId), y + 3 + FONT_HEIGHT_SMALL, 16, 8, imgSFL1); - display->drawFastImage(x + SCREEN_WIDTH - 18 - display->getStringWidth(ourId), y + 11 + FONT_HEIGHT_SMALL, 16, 8, imgSFL2); + display->drawFastImage(x + SCREEN_WIDTH - 18 - display->getStringWidth(ourId), y + 3 + FONT_HEIGHT_SMALL, 16, 8, + imgSFL1); + display->drawFastImage(x + SCREEN_WIDTH - 18 - display->getStringWidth(ourId), y + 11 + FONT_HEIGHT_SMALL, 16, 8, + imgSFL2); #else - display->drawFastImage(x + SCREEN_WIDTH - 13 - display->getStringWidth(ourId), y + 2 + FONT_HEIGHT_SMALL, 11, 8, imgSF); + display->drawFastImage(x + SCREEN_WIDTH - 13 - display->getStringWidth(ourId), y + 2 + FONT_HEIGHT_SMALL, 11, 8, + imgSF); #endif } -#endif +#endif } else { #if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) - display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 3 + FONT_HEIGHT_SMALL, 12, 8, imgInfoL1); - display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 11 + FONT_HEIGHT_SMALL, 12, 8, imgInfoL2); + display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 3 + FONT_HEIGHT_SMALL, 12, 8, + imgInfoL1); + display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 11 + FONT_HEIGHT_SMALL, 12, 8, + imgInfoL2); #else display->drawFastImage(x + SCREEN_WIDTH - 10 - display->getStringWidth(ourId), y + 2 + FONT_HEIGHT_SMALL, 8, 8, imgInfo); #endif @@ -1510,16 +1519,16 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i if (WiFi.status() != WL_CONNECTED) { display->drawString(x, y, String("WiFi: Not Connected")); - if(config.display.heading_bold) + if (config.display.heading_bold) display->drawString(x + 1, y, String("WiFi: Not Connected")); } else { display->drawString(x, y, String("WiFi: Connected")); - if(config.display.heading_bold) + if (config.display.heading_bold) display->drawString(x + 1, y, String("WiFi: Connected")); display->drawString(x + SCREEN_WIDTH - display->getStringWidth("RSSI " + String(WiFi.RSSI())), y, "RSSI " + String(WiFi.RSSI())); - if(config.display.heading_bold) { + if (config.display.heading_bold) { display->drawString(x + SCREEN_WIDTH - display->getStringWidth("RSSI " + String(WiFi.RSSI())) - 1, y, "RSSI " + String(WiFi.RSSI())); } @@ -1650,12 +1659,12 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat // Line 1 display->drawString(x, y, batStr); - if(config.display.heading_bold) + if (config.display.heading_bold) display->drawString(x + 1, y, batStr); } else { // Line 1 display->drawString(x, y, String("USB")); - if(config.display.heading_bold) + if (config.display.heading_bold) display->drawString(x + 1, y, String("USB")); } @@ -1689,7 +1698,7 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat } display->drawString(x + SCREEN_WIDTH - display->getStringWidth(mode), y, mode); - if(config.display.heading_bold) + if (config.display.heading_bold) display->drawString(x + SCREEN_WIDTH - display->getStringWidth(mode) - 1, y, mode); // Line 2 @@ -1740,17 +1749,16 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat char chUtil[13]; snprintf(chUtil, sizeof(chUtil), "ChUtil %2.0f%%", airTime->channelUtilizationPercent()); display->drawString(x + SCREEN_WIDTH - display->getStringWidth(chUtil), y + FONT_HEIGHT_SMALL * 1, chUtil); -if (config.position.gps_enabled) { - // Line 3 - if (config.display.gps_format != - Config_DisplayConfig_GpsCoordinateFormat_DMS) // if DMS then don't draw altitude - drawGPSAltitude(display, x, y + FONT_HEIGHT_SMALL * 2, gpsStatus); + if (config.position.gps_enabled) { + // Line 3 + if (config.display.gps_format != Config_DisplayConfig_GpsCoordinateFormat_DMS) // if DMS then don't draw altitude + drawGPSAltitude(display, x, y + FONT_HEIGHT_SMALL * 2, gpsStatus); - // Line 4 - drawGPScoordinates(display, x, y + FONT_HEIGHT_SMALL * 3, gpsStatus); -} else { - drawGPSpowerstat(display, x - (SCREEN_WIDTH / 4), y + FONT_HEIGHT_SMALL * 2, gpsStatus); -} + // Line 4 + drawGPScoordinates(display, x, y + FONT_HEIGHT_SMALL * 3, gpsStatus); + } else { + drawGPSpowerstat(display, x - (SCREEN_WIDTH / 4), y + FONT_HEIGHT_SMALL * 2, gpsStatus); + } /* Display a heartbeat pixel that blinks every time the frame is redrawn */ #ifdef SHOW_REDRAWS if (heartbeat) diff --git a/src/main.h b/src/main.h index 89a6bd059..27aa06d6c 100644 --- a/src/main.h +++ b/src/main.h @@ -1,11 +1,11 @@ #pragma once -#include #include "GPSStatus.h" #include "NodeStatus.h" #include "PowerStatus.h" #include "graphics/Screen.h" -#include "mesh/generated/telemetry.pb.h" +#include "mesh/generated/meshtastic/telemetry.pb.h" +#include #if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) #include #endif diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index 3f74e672d..7c5781879 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -6,6 +6,7 @@ #include "PowerFSM.h" #include "RadioInterface.h" #include "configuration.h" +#include "xmodem.h" #if FromRadio_size > MAX_TO_FROM_RADIO_SIZE #error FromRadio is too big @@ -31,6 +32,7 @@ void PhoneAPI::handleStartConfig() if (!isConnected()) { onConnectionChanged(true); observe(&service.fromNumChanged); + observe(&xModem.packetReady); } // even if we were already connected - restart our state machine @@ -48,6 +50,7 @@ void PhoneAPI::close() state = STATE_SEND_NOTHING; unobserve(&service.fromNumChanged); + unobserve(&xModem.packetReady); releasePhonePacket(); // Don't leak phone packets on shutdown releaseQueueStatusPhonePacket(); @@ -90,6 +93,10 @@ bool PhoneAPI::handleToRadio(const uint8_t *buf, size_t bufLength) LOG_INFO("Disconnecting from phone\n"); close(); break; + case ToRadio_xmodemPacket_tag: + LOG_INFO("Got xmodem packet\n"); + xModem.handlePacket(toRadioScratch.xmodemPacket); + break; default: // Ignore nop messages // LOG_DEBUG("Error: unexpected ToRadio variant\n"); @@ -150,7 +157,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) if (info) { LOG_INFO("Sending nodeinfo: num=0x%x, lastseen=%u, id=%s, name=%s\n", info->num, info->last_heard, info->user.id, - info->user.long_name); + info->user.long_name); fromRadioScratch.which_payload_variant = FromRadio_node_info_tag; fromRadioScratch.node_info = *info; // Stay in current state until done sending nodeinfos @@ -287,10 +294,14 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) // Do we have a message from the mesh? LOG_INFO("getFromRadio=STATE_SEND_PACKETS\n"); if (queueStatusPacketForPhone) { - fromRadioScratch.which_payload_variant = FromRadio_queueStatus_tag; fromRadioScratch.queueStatus = *queueStatusPacketForPhone; releaseQueueStatusPhonePacket(); + } else if (xmodemPacketForPhone) { + fromRadioScratch.which_payload_variant = FromRadio_xmodemPacket_tag; + fromRadioScratch.xmodemPacket = *xmodemPacketForPhone; + free(xmodemPacketForPhone); + xmodemPacketForPhone = NULL; } else if (packetForPhone) { printPacket("phone downloaded packet", packetForPhone); @@ -353,6 +364,7 @@ bool PhoneAPI::available() case STATE_SEND_MODULECONFIG: case STATE_SEND_COMPLETE_ID: return true; + case STATE_SEND_NODEINFO: if (!nodeInfoForPhone) nodeInfoForPhone = nodeDB.readNextInfo(); @@ -365,6 +377,12 @@ bool PhoneAPI::available() if (hasPacket) return true; + if (!xmodemPacketForPhone) + xmodemPacketForPhone = xModem.getForPhone(); + hasPacket = !!packetForPhone; + if (hasPacket) + return true; + if (!packetForPhone) packetForPhone = service.getForPhone(); hasPacket = !!packetForPhone; diff --git a/src/mesh/PhoneAPI.h b/src/mesh/PhoneAPI.h index aa190ae37..bed917af2 100644 --- a/src/mesh/PhoneAPI.h +++ b/src/mesh/PhoneAPI.h @@ -16,14 +16,15 @@ * Eventually there should be once instance of this class for each live connection (because it has a bit of state * for that connection) */ -class PhoneAPI : public Observer // FIXME, we shouldn't be inheriting from Observer, instead use CallbackObserver as a member +class PhoneAPI + : public Observer // FIXME, we shouldn't be inheriting from Observer, instead use CallbackObserver as a member { enum State { - STATE_SEND_NOTHING, // Initial state, don't send anything until the client starts asking for config - STATE_SEND_MY_INFO, // send our my info record - STATE_SEND_NODEINFO, // states progress in this order as the device sends to to the client - STATE_SEND_CHANNELS, // Send all channels - STATE_SEND_CONFIG, // Replacement for the old Radioconfig + STATE_SEND_NOTHING, // Initial state, don't send anything until the client starts asking for config + STATE_SEND_MY_INFO, // send our my info record + STATE_SEND_NODEINFO, // states progress in this order as the device sends to to the client + STATE_SEND_CHANNELS, // Send all channels + STATE_SEND_CONFIG, // Replacement for the old Radioconfig STATE_SEND_MODULECONFIG, // Send Module specific config STATE_SEND_COMPLETE_ID, STATE_SEND_PACKETS // send packets or debug strings @@ -42,6 +43,9 @@ class PhoneAPI : public Observer // FIXME, we shouldn't be inheriting /// downloads it MeshPacket *packetForPhone = NULL; + // file transfer packets destined for phone. Push it to the queue then free it. + XModem *xmodemPacketForPhone = NULL; + // Keep QueueStatus packet just as packetForPhone QueueStatus *queueStatusPacketForPhone = NULL; @@ -62,7 +66,7 @@ class PhoneAPI : public Observer // FIXME, we shouldn't be inheriting // Call this when the client drops the connection, resets the state to STATE_SEND_NOTHING // Unregisters our observer. A closed connection **can** be reopened by calling init again. virtual void close(); - + /** * Handle a ToRadio protobuf * @return true true if a packet was queued for sending (so that caller can yield) @@ -92,7 +96,7 @@ class PhoneAPI : public Observer // FIXME, we shouldn't be inheriting /** the last msec we heard from the client on the other side of this link */ uint32_t lastContactMsec = 0; - + /// Hookable to find out when connection changes virtual void onConnectionChanged(bool connected) {} diff --git a/src/mesh/generated/.clang-format b/src/mesh/generated/.clang-format new file mode 100644 index 000000000..a43d914ec --- /dev/null +++ b/src/mesh/generated/.clang-format @@ -0,0 +1,2 @@ +DisableFormat: true +SortIncludes: false \ No newline at end of file diff --git a/src/mesh/generated/admin.pb.c b/src/mesh/generated/meshtastic/admin.pb.c similarity index 91% rename from src/mesh/generated/admin.pb.c rename to src/mesh/generated/meshtastic/admin.pb.c index 3fdd0cb3d..8677e0feb 100644 --- a/src/mesh/generated/admin.pb.c +++ b/src/mesh/generated/meshtastic/admin.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.7 */ -#include "admin.pb.h" +#include "./admin.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/src/mesh/generated/admin.pb.h b/src/mesh/generated/meshtastic/admin.pb.h similarity index 88% rename from src/mesh/generated/admin.pb.h rename to src/mesh/generated/meshtastic/admin.pb.h index a00376f21..83aa7bbff 100644 --- a/src/mesh/generated/admin.pb.h +++ b/src/mesh/generated/meshtastic/admin.pb.h @@ -1,14 +1,14 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.7 */ -#ifndef PB_ADMIN_PB_H_INCLUDED -#define PB_ADMIN_PB_H_INCLUDED +#ifndef PB_MESHTASTIC_MESHTASTIC_ADMIN_PB_H_INCLUDED +#define PB_MESHTASTIC_MESHTASTIC_ADMIN_PB_H_INCLUDED #include -#include "channel.pb.h" -#include "config.pb.h" -#include "device_metadata.pb.h" -#include "mesh.pb.h" -#include "module_config.pb.h" +#include "./channel.pb.h" +#include "./config.pb.h" +#include "./device_metadata.pb.h" +#include "./mesh.pb.h" +#include "./module_config.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -155,40 +155,40 @@ extern "C" { /* Initializer values for message structs */ -#define AdminMessage_init_default {0, {0}} -#define AdminMessage_init_zero {0, {0}} +#define AdminMessage_init_default {0, {0}} +#define AdminMessage_init_zero {0, {0}} /* Field tags (for use in manual encoding/decoding) */ -#define AdminMessage_get_channel_request_tag 1 -#define AdminMessage_get_channel_response_tag 2 -#define AdminMessage_get_owner_request_tag 3 -#define AdminMessage_get_owner_response_tag 4 -#define AdminMessage_get_config_request_tag 5 -#define AdminMessage_get_config_response_tag 6 +#define AdminMessage_get_channel_request_tag 1 +#define AdminMessage_get_channel_response_tag 2 +#define AdminMessage_get_owner_request_tag 3 +#define AdminMessage_get_owner_response_tag 4 +#define AdminMessage_get_config_request_tag 5 +#define AdminMessage_get_config_response_tag 6 #define AdminMessage_get_module_config_request_tag 7 #define AdminMessage_get_module_config_response_tag 8 #define AdminMessage_get_canned_message_module_messages_request_tag 10 #define AdminMessage_get_canned_message_module_messages_response_tag 11 #define AdminMessage_get_device_metadata_request_tag 12 #define AdminMessage_get_device_metadata_response_tag 13 -#define AdminMessage_get_ringtone_request_tag 14 -#define AdminMessage_get_ringtone_response_tag 15 -#define AdminMessage_set_owner_tag 32 -#define AdminMessage_set_channel_tag 33 -#define AdminMessage_set_config_tag 34 -#define AdminMessage_set_module_config_tag 35 +#define AdminMessage_get_ringtone_request_tag 14 +#define AdminMessage_get_ringtone_response_tag 15 +#define AdminMessage_set_owner_tag 32 +#define AdminMessage_set_channel_tag 33 +#define AdminMessage_set_config_tag 34 +#define AdminMessage_set_module_config_tag 35 #define AdminMessage_set_canned_message_module_messages_tag 36 -#define AdminMessage_set_ringtone_message_tag 37 -#define AdminMessage_begin_edit_settings_tag 64 -#define AdminMessage_commit_edit_settings_tag 65 -#define AdminMessage_confirm_set_channel_tag 66 -#define AdminMessage_confirm_set_radio_tag 67 -#define AdminMessage_reboot_ota_seconds_tag 95 -#define AdminMessage_exit_simulator_tag 96 -#define AdminMessage_reboot_seconds_tag 97 -#define AdminMessage_shutdown_seconds_tag 98 -#define AdminMessage_factory_reset_tag 99 -#define AdminMessage_nodedb_reset_tag 100 +#define AdminMessage_set_ringtone_message_tag 37 +#define AdminMessage_begin_edit_settings_tag 64 +#define AdminMessage_commit_edit_settings_tag 65 +#define AdminMessage_confirm_set_channel_tag 66 +#define AdminMessage_confirm_set_radio_tag 67 +#define AdminMessage_reboot_ota_seconds_tag 95 +#define AdminMessage_exit_simulator_tag 96 +#define AdminMessage_reboot_seconds_tag 97 +#define AdminMessage_shutdown_seconds_tag 98 +#define AdminMessage_factory_reset_tag 99 +#define AdminMessage_nodedb_reset_tag 100 /* Struct field encoding specification for nanopb */ #define AdminMessage_FIELDLIST(X, a) \ @@ -240,7 +240,7 @@ extern const pb_msgdesc_t AdminMessage_msg; #define AdminMessage_fields &AdminMessage_msg /* Maximum encoded size of messages (where known) */ -#define AdminMessage_size 234 +#define AdminMessage_size 234 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/apponly.pb.c b/src/mesh/generated/meshtastic/apponly.pb.c similarity index 90% rename from src/mesh/generated/apponly.pb.c rename to src/mesh/generated/meshtastic/apponly.pb.c index ce68d47c6..8360eaa34 100644 --- a/src/mesh/generated/apponly.pb.c +++ b/src/mesh/generated/meshtastic/apponly.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.7 */ -#include "apponly.pb.h" +#include "./apponly.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/src/mesh/generated/apponly.pb.h b/src/mesh/generated/meshtastic/apponly.pb.h similarity index 63% rename from src/mesh/generated/apponly.pb.h rename to src/mesh/generated/meshtastic/apponly.pb.h index e0a6d7cd5..a37ba8ab5 100644 --- a/src/mesh/generated/apponly.pb.h +++ b/src/mesh/generated/meshtastic/apponly.pb.h @@ -1,11 +1,11 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.7 */ -#ifndef PB_APPONLY_PB_H_INCLUDED -#define PB_APPONLY_PB_H_INCLUDED +#ifndef PB_MESHTASTIC_MESHTASTIC_APPONLY_PB_H_INCLUDED +#define PB_MESHTASTIC_MESHTASTIC_APPONLY_PB_H_INCLUDED #include -#include "channel.pb.h" -#include "config.pb.h" +#include "./channel.pb.h" +#include "./config.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -32,12 +32,12 @@ extern "C" { #endif /* Initializer values for message structs */ -#define ChannelSet_init_default {0, {ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default}, false, Config_LoRaConfig_init_default} -#define ChannelSet_init_zero {0, {ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero}, false, Config_LoRaConfig_init_zero} +#define ChannelSet_init_default {0, {ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default, ChannelSettings_init_default}, false, Config_LoRaConfig_init_default} +#define ChannelSet_init_zero {0, {ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero, ChannelSettings_init_zero}, false, Config_LoRaConfig_init_zero} /* Field tags (for use in manual encoding/decoding) */ -#define ChannelSet_settings_tag 1 -#define ChannelSet_lora_config_tag 2 +#define ChannelSet_settings_tag 1 +#define ChannelSet_lora_config_tag 2 /* Struct field encoding specification for nanopb */ #define ChannelSet_FIELDLIST(X, a) \ @@ -54,7 +54,7 @@ extern const pb_msgdesc_t ChannelSet_msg; #define ChannelSet_fields &ChannelSet_msg /* Maximum encoded size of messages (where known) */ -#define ChannelSet_size 584 +#define ChannelSet_size 584 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/cannedmessages.pb.c b/src/mesh/generated/meshtastic/cannedmessages.pb.c similarity index 89% rename from src/mesh/generated/cannedmessages.pb.c rename to src/mesh/generated/meshtastic/cannedmessages.pb.c index 448517f13..5fb8adfd0 100644 --- a/src/mesh/generated/cannedmessages.pb.c +++ b/src/mesh/generated/meshtastic/cannedmessages.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.7 */ -#include "cannedmessages.pb.h" +#include "./cannedmessages.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/src/mesh/generated/cannedmessages.pb.h b/src/mesh/generated/meshtastic/cannedmessages.pb.h similarity index 78% rename from src/mesh/generated/cannedmessages.pb.h rename to src/mesh/generated/meshtastic/cannedmessages.pb.h index 4981fef18..e2f0426f2 100644 --- a/src/mesh/generated/cannedmessages.pb.h +++ b/src/mesh/generated/meshtastic/cannedmessages.pb.h @@ -1,8 +1,8 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.7 */ -#ifndef PB_CANNEDMESSAGES_PB_H_INCLUDED -#define PB_CANNEDMESSAGES_PB_H_INCLUDED +#ifndef PB_MESHTASTIC_MESHTASTIC_CANNEDMESSAGES_PB_H_INCLUDED +#define PB_MESHTASTIC_MESHTASTIC_CANNEDMESSAGES_PB_H_INCLUDED #include #if PB_PROTO_HEADER_VERSION != 40 @@ -22,11 +22,11 @@ extern "C" { #endif /* Initializer values for message structs */ -#define CannedMessageModuleConfig_init_default {""} -#define CannedMessageModuleConfig_init_zero {""} +#define CannedMessageModuleConfig_init_default {""} +#define CannedMessageModuleConfig_init_zero {""} /* Field tags (for use in manual encoding/decoding) */ -#define CannedMessageModuleConfig_messages_tag 1 +#define CannedMessageModuleConfig_messages_tag 1 /* Struct field encoding specification for nanopb */ #define CannedMessageModuleConfig_FIELDLIST(X, a) \ @@ -40,7 +40,7 @@ extern const pb_msgdesc_t CannedMessageModuleConfig_msg; #define CannedMessageModuleConfig_fields &CannedMessageModuleConfig_msg /* Maximum encoded size of messages (where known) */ -#define CannedMessageModuleConfig_size 203 +#define CannedMessageModuleConfig_size 203 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/channel.pb.c b/src/mesh/generated/meshtastic/channel.pb.c similarity index 91% rename from src/mesh/generated/channel.pb.c rename to src/mesh/generated/meshtastic/channel.pb.c index d8e4d8332..b22ec0b36 100644 --- a/src/mesh/generated/channel.pb.c +++ b/src/mesh/generated/meshtastic/channel.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.7 */ -#include "channel.pb.h" +#include "./channel.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/src/mesh/generated/channel.pb.h b/src/mesh/generated/meshtastic/channel.pb.h similarity index 87% rename from src/mesh/generated/channel.pb.h rename to src/mesh/generated/meshtastic/channel.pb.h index 2dc16bce5..8c287eca8 100644 --- a/src/mesh/generated/channel.pb.h +++ b/src/mesh/generated/meshtastic/channel.pb.h @@ -1,8 +1,8 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.7 */ -#ifndef PB_CHANNEL_PB_H_INCLUDED -#define PB_CHANNEL_PB_H_INCLUDED +#ifndef PB_MESHTASTIC_MESHTASTIC_CHANNEL_PB_H_INCLUDED +#define PB_MESHTASTIC_MESHTASTIC_CHANNEL_PB_H_INCLUDED #include #if PB_PROTO_HEADER_VERSION != 40 @@ -119,21 +119,21 @@ extern "C" { /* Initializer values for message structs */ -#define ChannelSettings_init_default {0, {0, {0}}, "", 0, 0, 0} -#define Channel_init_default {0, false, ChannelSettings_init_default, _Channel_Role_MIN} -#define ChannelSettings_init_zero {0, {0, {0}}, "", 0, 0, 0} -#define Channel_init_zero {0, false, ChannelSettings_init_zero, _Channel_Role_MIN} +#define ChannelSettings_init_default {0, {0, {0}}, "", 0, 0, 0} +#define Channel_init_default {0, false, ChannelSettings_init_default, _Channel_Role_MIN} +#define ChannelSettings_init_zero {0, {0, {0}}, "", 0, 0, 0} +#define Channel_init_zero {0, false, ChannelSettings_init_zero, _Channel_Role_MIN} /* Field tags (for use in manual encoding/decoding) */ -#define ChannelSettings_channel_num_tag 1 -#define ChannelSettings_psk_tag 2 -#define ChannelSettings_name_tag 3 -#define ChannelSettings_id_tag 4 -#define ChannelSettings_uplink_enabled_tag 5 -#define ChannelSettings_downlink_enabled_tag 6 -#define Channel_index_tag 1 -#define Channel_settings_tag 2 -#define Channel_role_tag 3 +#define ChannelSettings_channel_num_tag 1 +#define ChannelSettings_psk_tag 2 +#define ChannelSettings_name_tag 3 +#define ChannelSettings_id_tag 4 +#define ChannelSettings_uplink_enabled_tag 5 +#define ChannelSettings_downlink_enabled_tag 6 +#define Channel_index_tag 1 +#define Channel_settings_tag 2 +#define Channel_role_tag 3 /* Struct field encoding specification for nanopb */ #define ChannelSettings_FIELDLIST(X, a) \ @@ -162,8 +162,8 @@ extern const pb_msgdesc_t Channel_msg; #define Channel_fields &Channel_msg /* Maximum encoded size of messages (where known) */ -#define ChannelSettings_size 62 -#define Channel_size 77 +#define ChannelSettings_size 62 +#define Channel_size 77 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/config.pb.c b/src/mesh/generated/meshtastic/config.pb.c similarity index 96% rename from src/mesh/generated/config.pb.c rename to src/mesh/generated/meshtastic/config.pb.c index d43f4beae..bd65fee30 100644 --- a/src/mesh/generated/config.pb.c +++ b/src/mesh/generated/meshtastic/config.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.7 */ -#include "config.pb.h" +#include "./config.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/src/mesh/generated/config.pb.h b/src/mesh/generated/meshtastic/config.pb.h similarity index 85% rename from src/mesh/generated/config.pb.h rename to src/mesh/generated/meshtastic/config.pb.h index a6c84306e..f49c330d9 100644 --- a/src/mesh/generated/config.pb.h +++ b/src/mesh/generated/meshtastic/config.pb.h @@ -1,8 +1,8 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.7 */ -#ifndef PB_CONFIG_PB_H_INCLUDED -#define PB_CONFIG_PB_H_INCLUDED +#ifndef PB_MESHTASTIC_MESHTASTIC_CONFIG_PB_H_INCLUDED +#define PB_MESHTASTIC_MESHTASTIC_CONFIG_PB_H_INCLUDED #include #if PB_PROTO_HEADER_VERSION != 40 @@ -300,6 +300,8 @@ typedef struct _Config_NetworkConfig { /* struct to keep static address */ bool has_ipv4_config; Config_NetworkConfig_IpV4Config ipv4_config; + /* rsyslog Server and Port */ + char rsyslog_server[33]; } Config_NetworkConfig; /* Display Config */ @@ -472,91 +474,92 @@ extern "C" { /* Initializer values for message structs */ -#define Config_init_default {0, {Config_DeviceConfig_init_default}} -#define Config_DeviceConfig_init_default {_Config_DeviceConfig_Role_MIN, 0, 0, 0, 0} -#define Config_PositionConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0} -#define Config_PowerConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0} -#define Config_NetworkConfig_init_default {0, "", "", "", 0, _Config_NetworkConfig_AddressMode_MIN, false, Config_NetworkConfig_IpV4Config_init_default} +#define Config_init_default {0, {Config_DeviceConfig_init_default}} +#define Config_DeviceConfig_init_default {_Config_DeviceConfig_Role_MIN, 0, 0, 0, 0} +#define Config_PositionConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0} +#define Config_PowerConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0} +#define Config_NetworkConfig_init_default {0, "", "", "", 0, _Config_NetworkConfig_AddressMode_MIN, false, Config_NetworkConfig_IpV4Config_init_default, ""} #define Config_NetworkConfig_IpV4Config_init_default {0, 0, 0, 0} -#define Config_DisplayConfig_init_default {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN, _Config_DisplayConfig_OledType_MIN, _Config_DisplayConfig_DisplayMode_MIN, 0} -#define Config_LoRaConfig_init_default {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, 0, {0, 0, 0}} -#define Config_BluetoothConfig_init_default {0, _Config_BluetoothConfig_PairingMode_MIN, 0} -#define Config_init_zero {0, {Config_DeviceConfig_init_zero}} -#define Config_DeviceConfig_init_zero {_Config_DeviceConfig_Role_MIN, 0, 0, 0, 0} -#define Config_PositionConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0} -#define Config_PowerConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0} -#define Config_NetworkConfig_init_zero {0, "", "", "", 0, _Config_NetworkConfig_AddressMode_MIN, false, Config_NetworkConfig_IpV4Config_init_zero} +#define Config_DisplayConfig_init_default {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN, _Config_DisplayConfig_OledType_MIN, _Config_DisplayConfig_DisplayMode_MIN, 0} +#define Config_LoRaConfig_init_default {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, 0, {0, 0, 0}} +#define Config_BluetoothConfig_init_default {0, _Config_BluetoothConfig_PairingMode_MIN, 0} +#define Config_init_zero {0, {Config_DeviceConfig_init_zero}} +#define Config_DeviceConfig_init_zero {_Config_DeviceConfig_Role_MIN, 0, 0, 0, 0} +#define Config_PositionConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0} +#define Config_PowerConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0} +#define Config_NetworkConfig_init_zero {0, "", "", "", 0, _Config_NetworkConfig_AddressMode_MIN, false, Config_NetworkConfig_IpV4Config_init_zero, ""} #define Config_NetworkConfig_IpV4Config_init_zero {0, 0, 0, 0} -#define Config_DisplayConfig_init_zero {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN, _Config_DisplayConfig_OledType_MIN, _Config_DisplayConfig_DisplayMode_MIN, 0} -#define Config_LoRaConfig_init_zero {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, 0, {0, 0, 0}} -#define Config_BluetoothConfig_init_zero {0, _Config_BluetoothConfig_PairingMode_MIN, 0} +#define Config_DisplayConfig_init_zero {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN, _Config_DisplayConfig_OledType_MIN, _Config_DisplayConfig_DisplayMode_MIN, 0} +#define Config_LoRaConfig_init_zero {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, 0, {0, 0, 0}} +#define Config_BluetoothConfig_init_zero {0, _Config_BluetoothConfig_PairingMode_MIN, 0} /* Field tags (for use in manual encoding/decoding) */ -#define Config_DeviceConfig_role_tag 1 -#define Config_DeviceConfig_serial_enabled_tag 2 +#define Config_DeviceConfig_role_tag 1 +#define Config_DeviceConfig_serial_enabled_tag 2 #define Config_DeviceConfig_debug_log_enabled_tag 3 -#define Config_DeviceConfig_button_gpio_tag 4 -#define Config_DeviceConfig_buzzer_gpio_tag 5 +#define Config_DeviceConfig_button_gpio_tag 4 +#define Config_DeviceConfig_buzzer_gpio_tag 5 #define Config_PositionConfig_position_broadcast_secs_tag 1 #define Config_PositionConfig_position_broadcast_smart_enabled_tag 2 #define Config_PositionConfig_fixed_position_tag 3 -#define Config_PositionConfig_gps_enabled_tag 4 +#define Config_PositionConfig_gps_enabled_tag 4 #define Config_PositionConfig_gps_update_interval_tag 5 #define Config_PositionConfig_gps_attempt_time_tag 6 #define Config_PositionConfig_position_flags_tag 7 -#define Config_PositionConfig_rx_gpio_tag 8 -#define Config_PositionConfig_tx_gpio_tag 9 -#define Config_PowerConfig_is_power_saving_tag 1 +#define Config_PositionConfig_rx_gpio_tag 8 +#define Config_PositionConfig_tx_gpio_tag 9 +#define Config_PowerConfig_is_power_saving_tag 1 #define Config_PowerConfig_on_battery_shutdown_after_secs_tag 2 #define Config_PowerConfig_adc_multiplier_override_tag 3 #define Config_PowerConfig_wait_bluetooth_secs_tag 4 #define Config_PowerConfig_mesh_sds_timeout_secs_tag 5 -#define Config_PowerConfig_sds_secs_tag 6 -#define Config_PowerConfig_ls_secs_tag 7 -#define Config_PowerConfig_min_wake_secs_tag 8 -#define Config_NetworkConfig_IpV4Config_ip_tag 1 +#define Config_PowerConfig_sds_secs_tag 6 +#define Config_PowerConfig_ls_secs_tag 7 +#define Config_PowerConfig_min_wake_secs_tag 8 +#define Config_NetworkConfig_IpV4Config_ip_tag 1 #define Config_NetworkConfig_IpV4Config_gateway_tag 2 #define Config_NetworkConfig_IpV4Config_subnet_tag 3 -#define Config_NetworkConfig_IpV4Config_dns_tag 4 -#define Config_NetworkConfig_wifi_enabled_tag 1 -#define Config_NetworkConfig_wifi_ssid_tag 3 -#define Config_NetworkConfig_wifi_psk_tag 4 -#define Config_NetworkConfig_ntp_server_tag 5 -#define Config_NetworkConfig_eth_enabled_tag 6 -#define Config_NetworkConfig_address_mode_tag 7 -#define Config_NetworkConfig_ipv4_config_tag 8 -#define Config_DisplayConfig_screen_on_secs_tag 1 -#define Config_DisplayConfig_gps_format_tag 2 +#define Config_NetworkConfig_IpV4Config_dns_tag 4 +#define Config_NetworkConfig_wifi_enabled_tag 1 +#define Config_NetworkConfig_wifi_ssid_tag 3 +#define Config_NetworkConfig_wifi_psk_tag 4 +#define Config_NetworkConfig_ntp_server_tag 5 +#define Config_NetworkConfig_eth_enabled_tag 6 +#define Config_NetworkConfig_address_mode_tag 7 +#define Config_NetworkConfig_ipv4_config_tag 8 +#define Config_NetworkConfig_rsyslog_server_tag 9 +#define Config_DisplayConfig_screen_on_secs_tag 1 +#define Config_DisplayConfig_gps_format_tag 2 #define Config_DisplayConfig_auto_screen_carousel_secs_tag 3 #define Config_DisplayConfig_compass_north_top_tag 4 -#define Config_DisplayConfig_flip_screen_tag 5 -#define Config_DisplayConfig_units_tag 6 -#define Config_DisplayConfig_oled_tag 7 -#define Config_DisplayConfig_displaymode_tag 8 -#define Config_DisplayConfig_heading_bold_tag 9 -#define Config_LoRaConfig_use_preset_tag 1 -#define Config_LoRaConfig_modem_preset_tag 2 -#define Config_LoRaConfig_bandwidth_tag 3 -#define Config_LoRaConfig_spread_factor_tag 4 -#define Config_LoRaConfig_coding_rate_tag 5 -#define Config_LoRaConfig_frequency_offset_tag 6 -#define Config_LoRaConfig_region_tag 7 -#define Config_LoRaConfig_hop_limit_tag 8 -#define Config_LoRaConfig_tx_enabled_tag 9 -#define Config_LoRaConfig_tx_power_tag 10 -#define Config_LoRaConfig_channel_num_tag 11 +#define Config_DisplayConfig_flip_screen_tag 5 +#define Config_DisplayConfig_units_tag 6 +#define Config_DisplayConfig_oled_tag 7 +#define Config_DisplayConfig_displaymode_tag 8 +#define Config_DisplayConfig_heading_bold_tag 9 +#define Config_LoRaConfig_use_preset_tag 1 +#define Config_LoRaConfig_modem_preset_tag 2 +#define Config_LoRaConfig_bandwidth_tag 3 +#define Config_LoRaConfig_spread_factor_tag 4 +#define Config_LoRaConfig_coding_rate_tag 5 +#define Config_LoRaConfig_frequency_offset_tag 6 +#define Config_LoRaConfig_region_tag 7 +#define Config_LoRaConfig_hop_limit_tag 8 +#define Config_LoRaConfig_tx_enabled_tag 9 +#define Config_LoRaConfig_tx_power_tag 10 +#define Config_LoRaConfig_channel_num_tag 11 #define Config_LoRaConfig_override_duty_cycle_tag 12 -#define Config_LoRaConfig_ignore_incoming_tag 103 -#define Config_BluetoothConfig_enabled_tag 1 -#define Config_BluetoothConfig_mode_tag 2 -#define Config_BluetoothConfig_fixed_pin_tag 3 -#define Config_device_tag 1 -#define Config_position_tag 2 -#define Config_power_tag 3 -#define Config_network_tag 4 -#define Config_display_tag 5 -#define Config_lora_tag 6 -#define Config_bluetooth_tag 7 +#define Config_LoRaConfig_ignore_incoming_tag 103 +#define Config_BluetoothConfig_enabled_tag 1 +#define Config_BluetoothConfig_mode_tag 2 +#define Config_BluetoothConfig_fixed_pin_tag 3 +#define Config_device_tag 1 +#define Config_position_tag 2 +#define Config_power_tag 3 +#define Config_network_tag 4 +#define Config_display_tag 5 +#define Config_lora_tag 6 +#define Config_bluetooth_tag 7 /* Struct field encoding specification for nanopb */ #define Config_FIELDLIST(X, a) \ @@ -618,7 +621,8 @@ X(a, STATIC, SINGULAR, STRING, wifi_psk, 4) \ X(a, STATIC, SINGULAR, STRING, ntp_server, 5) \ X(a, STATIC, SINGULAR, BOOL, eth_enabled, 6) \ X(a, STATIC, SINGULAR, UENUM, address_mode, 7) \ -X(a, STATIC, OPTIONAL, MESSAGE, ipv4_config, 8) +X(a, STATIC, OPTIONAL, MESSAGE, ipv4_config, 8) \ +X(a, STATIC, SINGULAR, STRING, rsyslog_server, 9) #define Config_NetworkConfig_CALLBACK NULL #define Config_NetworkConfig_DEFAULT NULL #define Config_NetworkConfig_ipv4_config_MSGTYPE Config_NetworkConfig_IpV4Config @@ -690,15 +694,15 @@ extern const pb_msgdesc_t Config_BluetoothConfig_msg; #define Config_BluetoothConfig_fields &Config_BluetoothConfig_msg /* Maximum encoded size of messages (where known) */ -#define Config_BluetoothConfig_size 10 -#define Config_DeviceConfig_size 18 -#define Config_DisplayConfig_size 26 -#define Config_LoRaConfig_size 70 -#define Config_NetworkConfig_IpV4Config_size 20 -#define Config_NetworkConfig_size 161 -#define Config_PositionConfig_size 42 -#define Config_PowerConfig_size 43 -#define Config_size 164 +#define Config_BluetoothConfig_size 10 +#define Config_DeviceConfig_size 18 +#define Config_DisplayConfig_size 26 +#define Config_LoRaConfig_size 70 +#define Config_NetworkConfig_IpV4Config_size 20 +#define Config_NetworkConfig_size 195 +#define Config_PositionConfig_size 42 +#define Config_PowerConfig_size 43 +#define Config_size 198 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/device_metadata.pb.c b/src/mesh/generated/meshtastic/device_metadata.pb.c similarity index 88% rename from src/mesh/generated/device_metadata.pb.c rename to src/mesh/generated/meshtastic/device_metadata.pb.c index 92ff37121..725ac4c9f 100644 --- a/src/mesh/generated/device_metadata.pb.c +++ b/src/mesh/generated/meshtastic/device_metadata.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.7 */ -#include "device_metadata.pb.h" +#include "./device_metadata.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/src/mesh/generated/device_metadata.pb.h b/src/mesh/generated/meshtastic/device_metadata.pb.h similarity index 61% rename from src/mesh/generated/device_metadata.pb.h rename to src/mesh/generated/meshtastic/device_metadata.pb.h index b2ff9d7f5..cf6314e19 100644 --- a/src/mesh/generated/device_metadata.pb.h +++ b/src/mesh/generated/meshtastic/device_metadata.pb.h @@ -1,9 +1,10 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.7 */ -#ifndef PB_DEVICE_METADATA_PB_H_INCLUDED -#define PB_DEVICE_METADATA_PB_H_INCLUDED +#ifndef PB_MESHTASTIC_MESHTASTIC_DEVICE_METADATA_PB_H_INCLUDED +#define PB_MESHTASTIC_MESHTASTIC_DEVICE_METADATA_PB_H_INCLUDED #include +#include "./config.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -24,6 +25,10 @@ typedef struct _DeviceMetadata { bool hasBluetooth; /* Indicates that the device has an ethernet peripheral */ bool hasEthernet; + /* Indicates that the device's role in the mesh */ + Config_DeviceConfig_Role role; + /* Indicates the device's current enabled position flags */ + uint32_t position_flags; } DeviceMetadata; @@ -32,16 +37,18 @@ extern "C" { #endif /* Initializer values for message structs */ -#define DeviceMetadata_init_default {"", 0, 0, 0, 0, 0} -#define DeviceMetadata_init_zero {"", 0, 0, 0, 0, 0} +#define DeviceMetadata_init_default {"", 0, 0, 0, 0, 0, _Config_DeviceConfig_Role_MIN, 0} +#define DeviceMetadata_init_zero {"", 0, 0, 0, 0, 0, _Config_DeviceConfig_Role_MIN, 0} /* Field tags (for use in manual encoding/decoding) */ -#define DeviceMetadata_firmware_version_tag 1 -#define DeviceMetadata_device_state_version_tag 2 -#define DeviceMetadata_canShutdown_tag 3 -#define DeviceMetadata_hasWifi_tag 4 -#define DeviceMetadata_hasBluetooth_tag 5 -#define DeviceMetadata_hasEthernet_tag 6 +#define DeviceMetadata_firmware_version_tag 1 +#define DeviceMetadata_device_state_version_tag 2 +#define DeviceMetadata_canShutdown_tag 3 +#define DeviceMetadata_hasWifi_tag 4 +#define DeviceMetadata_hasBluetooth_tag 5 +#define DeviceMetadata_hasEthernet_tag 6 +#define DeviceMetadata_role_tag 7 +#define DeviceMetadata_position_flags_tag 8 /* Struct field encoding specification for nanopb */ #define DeviceMetadata_FIELDLIST(X, a) \ @@ -50,7 +57,9 @@ X(a, STATIC, SINGULAR, UINT32, device_state_version, 2) \ X(a, STATIC, SINGULAR, BOOL, canShutdown, 3) \ X(a, STATIC, SINGULAR, BOOL, hasWifi, 4) \ X(a, STATIC, SINGULAR, BOOL, hasBluetooth, 5) \ -X(a, STATIC, SINGULAR, BOOL, hasEthernet, 6) +X(a, STATIC, SINGULAR, BOOL, hasEthernet, 6) \ +X(a, STATIC, SINGULAR, UENUM, role, 7) \ +X(a, STATIC, SINGULAR, UINT32, position_flags, 8) #define DeviceMetadata_CALLBACK NULL #define DeviceMetadata_DEFAULT NULL @@ -60,7 +69,7 @@ extern const pb_msgdesc_t DeviceMetadata_msg; #define DeviceMetadata_fields &DeviceMetadata_msg /* Maximum encoded size of messages (where known) */ -#define DeviceMetadata_size 33 +#define DeviceMetadata_size 41 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/deviceonly.pb.c b/src/mesh/generated/meshtastic/deviceonly.pb.c similarity index 91% rename from src/mesh/generated/deviceonly.pb.c rename to src/mesh/generated/meshtastic/deviceonly.pb.c index e3acb0db4..0b26e68d1 100644 --- a/src/mesh/generated/deviceonly.pb.c +++ b/src/mesh/generated/meshtastic/deviceonly.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.7 */ -#include "deviceonly.pb.h" +#include "./deviceonly.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/src/mesh/generated/deviceonly.pb.h b/src/mesh/generated/meshtastic/deviceonly.pb.h similarity index 63% rename from src/mesh/generated/deviceonly.pb.h rename to src/mesh/generated/meshtastic/deviceonly.pb.h index 1a95a0970..234b65d00 100644 --- a/src/mesh/generated/deviceonly.pb.h +++ b/src/mesh/generated/meshtastic/deviceonly.pb.h @@ -1,11 +1,11 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.7 */ -#ifndef PB_DEVICEONLY_PB_H_INCLUDED -#define PB_DEVICEONLY_PB_H_INCLUDED +#ifndef PB_MESHTASTIC_MESHTASTIC_DEVICEONLY_PB_H_INCLUDED +#define PB_MESHTASTIC_MESHTASTIC_DEVICEONLY_PB_H_INCLUDED #include -#include "channel.pb.h" -#include "mesh.pb.h" +#include "./channel.pb.h" +#include "./mesh.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -103,30 +103,30 @@ extern "C" { /* Initializer values for message structs */ -#define DeviceState_init_default {false, MyNodeInfo_init_default, false, User_init_default, 0, {NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default}, 0, {MeshPacket_init_default}, false, MeshPacket_init_default, 0, 0, 0} -#define ChannelFile_init_default {0, {Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default}, 0} -#define OEMStore_init_default {0, 0, {0, {0}}, _ScreenFonts_MIN, "", {0, {0}}} -#define DeviceState_init_zero {false, MyNodeInfo_init_zero, false, User_init_zero, 0, {NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero}, 0, {MeshPacket_init_zero}, false, MeshPacket_init_zero, 0, 0, 0} -#define ChannelFile_init_zero {0, {Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero}, 0} -#define OEMStore_init_zero {0, 0, {0, {0}}, _ScreenFonts_MIN, "", {0, {0}}} +#define DeviceState_init_default {false, MyNodeInfo_init_default, false, User_init_default, 0, {NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default}, 0, {MeshPacket_init_default}, false, MeshPacket_init_default, 0, 0, 0} +#define ChannelFile_init_default {0, {Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default, Channel_init_default}, 0} +#define OEMStore_init_default {0, 0, {0, {0}}, _ScreenFonts_MIN, "", {0, {0}}} +#define DeviceState_init_zero {false, MyNodeInfo_init_zero, false, User_init_zero, 0, {NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero}, 0, {MeshPacket_init_zero}, false, MeshPacket_init_zero, 0, 0, 0} +#define ChannelFile_init_zero {0, {Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero, Channel_init_zero}, 0} +#define OEMStore_init_zero {0, 0, {0, {0}}, _ScreenFonts_MIN, "", {0, {0}}} /* Field tags (for use in manual encoding/decoding) */ -#define DeviceState_my_node_tag 2 -#define DeviceState_owner_tag 3 -#define DeviceState_node_db_tag 4 -#define DeviceState_receive_queue_tag 5 -#define DeviceState_rx_text_message_tag 7 -#define DeviceState_version_tag 8 -#define DeviceState_no_save_tag 9 -#define DeviceState_did_gps_reset_tag 11 -#define ChannelFile_channels_tag 1 -#define ChannelFile_version_tag 2 -#define OEMStore_oem_icon_width_tag 1 -#define OEMStore_oem_icon_height_tag 2 -#define OEMStore_oem_icon_bits_tag 3 -#define OEMStore_oem_font_tag 4 -#define OEMStore_oem_text_tag 5 -#define OEMStore_oem_aes_key_tag 6 +#define DeviceState_my_node_tag 2 +#define DeviceState_owner_tag 3 +#define DeviceState_node_db_tag 4 +#define DeviceState_receive_queue_tag 5 +#define DeviceState_rx_text_message_tag 7 +#define DeviceState_version_tag 8 +#define DeviceState_no_save_tag 9 +#define DeviceState_did_gps_reset_tag 11 +#define ChannelFile_channels_tag 1 +#define ChannelFile_version_tag 2 +#define OEMStore_oem_icon_width_tag 1 +#define OEMStore_oem_icon_height_tag 2 +#define OEMStore_oem_icon_bits_tag 3 +#define OEMStore_oem_font_tag 4 +#define OEMStore_oem_text_tag 5 +#define OEMStore_oem_aes_key_tag 6 /* Struct field encoding specification for nanopb */ #define DeviceState_FIELDLIST(X, a) \ @@ -173,9 +173,9 @@ extern const pb_msgdesc_t OEMStore_msg; #define OEMStore_fields &OEMStore_msg /* Maximum encoded size of messages (where known) */ -#define ChannelFile_size 638 -#define DeviceState_size 21800 -#define OEMStore_size 2140 +#define ChannelFile_size 638 +#define DeviceState_size 21800 +#define OEMStore_size 2140 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/localonly.pb.c b/src/mesh/generated/meshtastic/localonly.pb.c similarity index 91% rename from src/mesh/generated/localonly.pb.c rename to src/mesh/generated/meshtastic/localonly.pb.c index 4eac55fd7..b6be65c46 100644 --- a/src/mesh/generated/localonly.pb.c +++ b/src/mesh/generated/meshtastic/localonly.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.7 */ -#include "localonly.pb.h" +#include "./localonly.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/src/mesh/generated/localonly.pb.h b/src/mesh/generated/meshtastic/localonly.pb.h similarity index 68% rename from src/mesh/generated/localonly.pb.h rename to src/mesh/generated/meshtastic/localonly.pb.h index 1e4aa633c..fbaa06666 100644 --- a/src/mesh/generated/localonly.pb.h +++ b/src/mesh/generated/meshtastic/localonly.pb.h @@ -1,11 +1,11 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.7 */ -#ifndef PB_LOCALONLY_PB_H_INCLUDED -#define PB_LOCALONLY_PB_H_INCLUDED +#ifndef PB_MESHTASTIC_MESHTASTIC_LOCALONLY_PB_H_INCLUDED +#define PB_MESHTASTIC_MESHTASTIC_LOCALONLY_PB_H_INCLUDED #include -#include "config.pb.h" -#include "module_config.pb.h" +#include "./config.pb.h" +#include "./module_config.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -80,30 +80,30 @@ extern "C" { #endif /* Initializer values for message structs */ -#define LocalConfig_init_default {false, Config_DeviceConfig_init_default, false, Config_PositionConfig_init_default, false, Config_PowerConfig_init_default, false, Config_NetworkConfig_init_default, false, Config_DisplayConfig_init_default, false, Config_LoRaConfig_init_default, false, Config_BluetoothConfig_init_default, 0} -#define LocalModuleConfig_init_default {false, ModuleConfig_MQTTConfig_init_default, false, ModuleConfig_SerialConfig_init_default, false, ModuleConfig_ExternalNotificationConfig_init_default, false, ModuleConfig_StoreForwardConfig_init_default, false, ModuleConfig_RangeTestConfig_init_default, false, ModuleConfig_TelemetryConfig_init_default, false, ModuleConfig_CannedMessageConfig_init_default, 0, false, ModuleConfig_AudioConfig_init_default, false, ModuleConfig_RemoteHardwareConfig_init_default} -#define LocalConfig_init_zero {false, Config_DeviceConfig_init_zero, false, Config_PositionConfig_init_zero, false, Config_PowerConfig_init_zero, false, Config_NetworkConfig_init_zero, false, Config_DisplayConfig_init_zero, false, Config_LoRaConfig_init_zero, false, Config_BluetoothConfig_init_zero, 0} -#define LocalModuleConfig_init_zero {false, ModuleConfig_MQTTConfig_init_zero, false, ModuleConfig_SerialConfig_init_zero, false, ModuleConfig_ExternalNotificationConfig_init_zero, false, ModuleConfig_StoreForwardConfig_init_zero, false, ModuleConfig_RangeTestConfig_init_zero, false, ModuleConfig_TelemetryConfig_init_zero, false, ModuleConfig_CannedMessageConfig_init_zero, 0, false, ModuleConfig_AudioConfig_init_zero, false, ModuleConfig_RemoteHardwareConfig_init_zero} +#define LocalConfig_init_default {false, Config_DeviceConfig_init_default, false, Config_PositionConfig_init_default, false, Config_PowerConfig_init_default, false, Config_NetworkConfig_init_default, false, Config_DisplayConfig_init_default, false, Config_LoRaConfig_init_default, false, Config_BluetoothConfig_init_default, 0} +#define LocalModuleConfig_init_default {false, ModuleConfig_MQTTConfig_init_default, false, ModuleConfig_SerialConfig_init_default, false, ModuleConfig_ExternalNotificationConfig_init_default, false, ModuleConfig_StoreForwardConfig_init_default, false, ModuleConfig_RangeTestConfig_init_default, false, ModuleConfig_TelemetryConfig_init_default, false, ModuleConfig_CannedMessageConfig_init_default, 0, false, ModuleConfig_AudioConfig_init_default, false, ModuleConfig_RemoteHardwareConfig_init_default} +#define LocalConfig_init_zero {false, Config_DeviceConfig_init_zero, false, Config_PositionConfig_init_zero, false, Config_PowerConfig_init_zero, false, Config_NetworkConfig_init_zero, false, Config_DisplayConfig_init_zero, false, Config_LoRaConfig_init_zero, false, Config_BluetoothConfig_init_zero, 0} +#define LocalModuleConfig_init_zero {false, ModuleConfig_MQTTConfig_init_zero, false, ModuleConfig_SerialConfig_init_zero, false, ModuleConfig_ExternalNotificationConfig_init_zero, false, ModuleConfig_StoreForwardConfig_init_zero, false, ModuleConfig_RangeTestConfig_init_zero, false, ModuleConfig_TelemetryConfig_init_zero, false, ModuleConfig_CannedMessageConfig_init_zero, 0, false, ModuleConfig_AudioConfig_init_zero, false, ModuleConfig_RemoteHardwareConfig_init_zero} /* Field tags (for use in manual encoding/decoding) */ -#define LocalConfig_device_tag 1 -#define LocalConfig_position_tag 2 -#define LocalConfig_power_tag 3 -#define LocalConfig_network_tag 4 -#define LocalConfig_display_tag 5 -#define LocalConfig_lora_tag 6 -#define LocalConfig_bluetooth_tag 7 -#define LocalConfig_version_tag 8 -#define LocalModuleConfig_mqtt_tag 1 -#define LocalModuleConfig_serial_tag 2 +#define LocalConfig_device_tag 1 +#define LocalConfig_position_tag 2 +#define LocalConfig_power_tag 3 +#define LocalConfig_network_tag 4 +#define LocalConfig_display_tag 5 +#define LocalConfig_lora_tag 6 +#define LocalConfig_bluetooth_tag 7 +#define LocalConfig_version_tag 8 +#define LocalModuleConfig_mqtt_tag 1 +#define LocalModuleConfig_serial_tag 2 #define LocalModuleConfig_external_notification_tag 3 -#define LocalModuleConfig_store_forward_tag 4 -#define LocalModuleConfig_range_test_tag 5 -#define LocalModuleConfig_telemetry_tag 6 -#define LocalModuleConfig_canned_message_tag 7 -#define LocalModuleConfig_version_tag 8 -#define LocalModuleConfig_audio_tag 9 -#define LocalModuleConfig_remote_hardware_tag 10 +#define LocalModuleConfig_store_forward_tag 4 +#define LocalModuleConfig_range_test_tag 5 +#define LocalModuleConfig_telemetry_tag 6 +#define LocalModuleConfig_canned_message_tag 7 +#define LocalModuleConfig_version_tag 8 +#define LocalModuleConfig_audio_tag 9 +#define LocalModuleConfig_remote_hardware_tag 10 /* Struct field encoding specification for nanopb */ #define LocalConfig_FIELDLIST(X, a) \ @@ -156,8 +156,8 @@ extern const pb_msgdesc_t LocalModuleConfig_msg; #define LocalModuleConfig_fields &LocalModuleConfig_msg /* Maximum encoded size of messages (where known) */ -#define LocalConfig_size 391 -#define LocalModuleConfig_size 412 +#define LocalConfig_size 425 +#define LocalModuleConfig_size 412 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/mesh.pb.c b/src/mesh/generated/meshtastic/mesh.pb.c similarity index 96% rename from src/mesh/generated/mesh.pb.c rename to src/mesh/generated/meshtastic/mesh.pb.c index 29594c612..bc9af848f 100644 --- a/src/mesh/generated/mesh.pb.c +++ b/src/mesh/generated/meshtastic/mesh.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.7 */ -#include "mesh.pb.h" +#include "./mesh.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h similarity index 83% rename from src/mesh/generated/mesh.pb.h rename to src/mesh/generated/meshtastic/mesh.pb.h index 2e0b66629..98cf8238b 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -1,15 +1,15 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.7 */ -#ifndef PB_MESH_PB_H_INCLUDED -#define PB_MESH_PB_H_INCLUDED +#ifndef PB_MESHTASTIC_MESHTASTIC_MESH_PB_H_INCLUDED +#define PB_MESHTASTIC_MESHTASTIC_MESH_PB_H_INCLUDED #include -#include "channel.pb.h" -#include "config.pb.h" -#include "module_config.pb.h" -#include "portnums.pb.h" -#include "telemetry.pb.h" -#include "xmodem.pb.h" +#include "./channel.pb.h" +#include "./config.pb.h" +#include "./module_config.pb.h" +#include "./portnums.pb.h" +#include "./telemetry.pb.h" +#include "./xmodem.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -781,145 +781,145 @@ extern "C" { /* Initializer values for message structs */ -#define Position_init_default {0, 0, 0, 0, _Position_LocSource_MIN, _Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} -#define User_init_default {"", "", "", {0}, _HardwareModel_MIN, 0} -#define RouteDiscovery_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}} -#define Routing_init_default {0, {RouteDiscovery_init_default}} -#define Data_init_default {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0} -#define Waypoint_init_default {0, 0, 0, 0, 0, "", "", 0} -#define MeshPacket_init_default {0, 0, 0, 0, {Data_init_default}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN} -#define NodeInfo_init_default {0, false, User_init_default, false, Position_init_default, 0, 0, false, DeviceMetrics_init_default} -#define MyNodeInfo_init_default {0, 0, 0, "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, 0, 0} -#define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN} -#define QueueStatus_init_default {0, 0, 0, 0} -#define FromRadio_init_default {0, 0, {MeshPacket_init_default}} -#define ToRadio_init_default {0, {MeshPacket_init_default}} -#define Compressed_init_default {_PortNum_MIN, {0, {0}}} -#define Position_init_zero {0, 0, 0, 0, _Position_LocSource_MIN, _Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} -#define User_init_zero {"", "", "", {0}, _HardwareModel_MIN, 0} -#define RouteDiscovery_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}} -#define Routing_init_zero {0, {RouteDiscovery_init_zero}} -#define Data_init_zero {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0} -#define Waypoint_init_zero {0, 0, 0, 0, 0, "", "", 0} -#define MeshPacket_init_zero {0, 0, 0, 0, {Data_init_zero}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN} -#define NodeInfo_init_zero {0, false, User_init_zero, false, Position_init_zero, 0, 0, false, DeviceMetrics_init_zero} -#define MyNodeInfo_init_zero {0, 0, 0, "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, 0, 0} -#define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN} -#define QueueStatus_init_zero {0, 0, 0, 0} -#define FromRadio_init_zero {0, 0, {MeshPacket_init_zero}} -#define ToRadio_init_zero {0, {MeshPacket_init_zero}} -#define Compressed_init_zero {_PortNum_MIN, {0, {0}}} +#define Position_init_default {0, 0, 0, 0, _Position_LocSource_MIN, _Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define User_init_default {"", "", "", {0}, _HardwareModel_MIN, 0} +#define RouteDiscovery_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}} +#define Routing_init_default {0, {RouteDiscovery_init_default}} +#define Data_init_default {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0} +#define Waypoint_init_default {0, 0, 0, 0, 0, "", "", 0} +#define MeshPacket_init_default {0, 0, 0, 0, {Data_init_default}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN} +#define NodeInfo_init_default {0, false, User_init_default, false, Position_init_default, 0, 0, false, DeviceMetrics_init_default} +#define MyNodeInfo_init_default {0, 0, 0, "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, 0, 0} +#define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN} +#define QueueStatus_init_default {0, 0, 0, 0} +#define FromRadio_init_default {0, 0, {MeshPacket_init_default}} +#define ToRadio_init_default {0, {MeshPacket_init_default}} +#define Compressed_init_default {_PortNum_MIN, {0, {0}}} +#define Position_init_zero {0, 0, 0, 0, _Position_LocSource_MIN, _Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define User_init_zero {"", "", "", {0}, _HardwareModel_MIN, 0} +#define RouteDiscovery_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}} +#define Routing_init_zero {0, {RouteDiscovery_init_zero}} +#define Data_init_zero {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0} +#define Waypoint_init_zero {0, 0, 0, 0, 0, "", "", 0} +#define MeshPacket_init_zero {0, 0, 0, 0, {Data_init_zero}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN} +#define NodeInfo_init_zero {0, false, User_init_zero, false, Position_init_zero, 0, 0, false, DeviceMetrics_init_zero} +#define MyNodeInfo_init_zero {0, 0, 0, "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, 0, 0} +#define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN} +#define QueueStatus_init_zero {0, 0, 0, 0} +#define FromRadio_init_zero {0, 0, {MeshPacket_init_zero}} +#define ToRadio_init_zero {0, {MeshPacket_init_zero}} +#define Compressed_init_zero {_PortNum_MIN, {0, {0}}} /* Field tags (for use in manual encoding/decoding) */ -#define Position_latitude_i_tag 1 -#define Position_longitude_i_tag 2 -#define Position_altitude_tag 3 -#define Position_time_tag 4 -#define Position_location_source_tag 5 -#define Position_altitude_source_tag 6 -#define Position_timestamp_tag 7 -#define Position_timestamp_millis_adjust_tag 8 -#define Position_altitude_hae_tag 9 +#define Position_latitude_i_tag 1 +#define Position_longitude_i_tag 2 +#define Position_altitude_tag 3 +#define Position_time_tag 4 +#define Position_location_source_tag 5 +#define Position_altitude_source_tag 6 +#define Position_timestamp_tag 7 +#define Position_timestamp_millis_adjust_tag 8 +#define Position_altitude_hae_tag 9 #define Position_altitude_geoidal_separation_tag 10 -#define Position_PDOP_tag 11 -#define Position_HDOP_tag 12 -#define Position_VDOP_tag 13 -#define Position_gps_accuracy_tag 14 -#define Position_ground_speed_tag 15 -#define Position_ground_track_tag 16 -#define Position_fix_quality_tag 17 -#define Position_fix_type_tag 18 -#define Position_sats_in_view_tag 19 -#define Position_sensor_id_tag 20 -#define Position_next_update_tag 21 -#define Position_seq_number_tag 22 -#define User_id_tag 1 -#define User_long_name_tag 2 -#define User_short_name_tag 3 -#define User_macaddr_tag 4 -#define User_hw_model_tag 5 -#define User_is_licensed_tag 6 -#define RouteDiscovery_route_tag 1 -#define Routing_route_request_tag 1 -#define Routing_route_reply_tag 2 -#define Routing_error_reason_tag 3 -#define Data_portnum_tag 1 -#define Data_payload_tag 2 -#define Data_want_response_tag 3 -#define Data_dest_tag 4 -#define Data_source_tag 5 -#define Data_request_id_tag 6 -#define Data_reply_id_tag 7 -#define Data_emoji_tag 8 -#define Waypoint_id_tag 1 -#define Waypoint_latitude_i_tag 2 -#define Waypoint_longitude_i_tag 3 -#define Waypoint_expire_tag 4 -#define Waypoint_locked_to_tag 5 -#define Waypoint_name_tag 6 -#define Waypoint_description_tag 7 -#define Waypoint_icon_tag 8 -#define MeshPacket_from_tag 1 -#define MeshPacket_to_tag 2 -#define MeshPacket_channel_tag 3 -#define MeshPacket_decoded_tag 4 -#define MeshPacket_encrypted_tag 5 -#define MeshPacket_id_tag 6 -#define MeshPacket_rx_time_tag 7 -#define MeshPacket_rx_snr_tag 8 -#define MeshPacket_hop_limit_tag 9 -#define MeshPacket_want_ack_tag 10 -#define MeshPacket_priority_tag 11 -#define MeshPacket_rx_rssi_tag 12 -#define MeshPacket_delayed_tag 13 -#define NodeInfo_num_tag 1 -#define NodeInfo_user_tag 2 -#define NodeInfo_position_tag 3 -#define NodeInfo_snr_tag 4 -#define NodeInfo_last_heard_tag 5 -#define NodeInfo_device_metrics_tag 6 -#define MyNodeInfo_my_node_num_tag 1 -#define MyNodeInfo_has_gps_tag 2 -#define MyNodeInfo_max_channels_tag 3 -#define MyNodeInfo_firmware_version_tag 4 -#define MyNodeInfo_error_code_tag 5 -#define MyNodeInfo_error_address_tag 6 -#define MyNodeInfo_error_count_tag 7 -#define MyNodeInfo_reboot_count_tag 8 -#define MyNodeInfo_bitrate_tag 9 -#define MyNodeInfo_message_timeout_msec_tag 10 -#define MyNodeInfo_min_app_version_tag 11 -#define MyNodeInfo_air_period_tx_tag 12 -#define MyNodeInfo_air_period_rx_tag 13 -#define MyNodeInfo_has_wifi_tag 14 -#define MyNodeInfo_channel_utilization_tag 15 -#define MyNodeInfo_air_util_tx_tag 16 -#define LogRecord_message_tag 1 -#define LogRecord_time_tag 2 -#define LogRecord_source_tag 3 -#define LogRecord_level_tag 4 -#define QueueStatus_res_tag 1 -#define QueueStatus_free_tag 2 -#define QueueStatus_maxlen_tag 3 -#define QueueStatus_mesh_packet_id_tag 4 -#define FromRadio_id_tag 1 -#define FromRadio_packet_tag 2 -#define FromRadio_my_info_tag 3 -#define FromRadio_node_info_tag 4 -#define FromRadio_config_tag 5 -#define FromRadio_log_record_tag 6 -#define FromRadio_config_complete_id_tag 7 -#define FromRadio_rebooted_tag 8 -#define FromRadio_moduleConfig_tag 9 -#define FromRadio_channel_tag 10 -#define FromRadio_queueStatus_tag 11 -#define FromRadio_xmodemPacket_tag 12 -#define ToRadio_packet_tag 1 -#define ToRadio_want_config_id_tag 3 -#define ToRadio_disconnect_tag 4 -#define ToRadio_xmodemPacket_tag 5 -#define Compressed_portnum_tag 1 -#define Compressed_data_tag 2 +#define Position_PDOP_tag 11 +#define Position_HDOP_tag 12 +#define Position_VDOP_tag 13 +#define Position_gps_accuracy_tag 14 +#define Position_ground_speed_tag 15 +#define Position_ground_track_tag 16 +#define Position_fix_quality_tag 17 +#define Position_fix_type_tag 18 +#define Position_sats_in_view_tag 19 +#define Position_sensor_id_tag 20 +#define Position_next_update_tag 21 +#define Position_seq_number_tag 22 +#define User_id_tag 1 +#define User_long_name_tag 2 +#define User_short_name_tag 3 +#define User_macaddr_tag 4 +#define User_hw_model_tag 5 +#define User_is_licensed_tag 6 +#define RouteDiscovery_route_tag 1 +#define Routing_route_request_tag 1 +#define Routing_route_reply_tag 2 +#define Routing_error_reason_tag 3 +#define Data_portnum_tag 1 +#define Data_payload_tag 2 +#define Data_want_response_tag 3 +#define Data_dest_tag 4 +#define Data_source_tag 5 +#define Data_request_id_tag 6 +#define Data_reply_id_tag 7 +#define Data_emoji_tag 8 +#define Waypoint_id_tag 1 +#define Waypoint_latitude_i_tag 2 +#define Waypoint_longitude_i_tag 3 +#define Waypoint_expire_tag 4 +#define Waypoint_locked_to_tag 5 +#define Waypoint_name_tag 6 +#define Waypoint_description_tag 7 +#define Waypoint_icon_tag 8 +#define MeshPacket_from_tag 1 +#define MeshPacket_to_tag 2 +#define MeshPacket_channel_tag 3 +#define MeshPacket_decoded_tag 4 +#define MeshPacket_encrypted_tag 5 +#define MeshPacket_id_tag 6 +#define MeshPacket_rx_time_tag 7 +#define MeshPacket_rx_snr_tag 8 +#define MeshPacket_hop_limit_tag 9 +#define MeshPacket_want_ack_tag 10 +#define MeshPacket_priority_tag 11 +#define MeshPacket_rx_rssi_tag 12 +#define MeshPacket_delayed_tag 13 +#define NodeInfo_num_tag 1 +#define NodeInfo_user_tag 2 +#define NodeInfo_position_tag 3 +#define NodeInfo_snr_tag 4 +#define NodeInfo_last_heard_tag 5 +#define NodeInfo_device_metrics_tag 6 +#define MyNodeInfo_my_node_num_tag 1 +#define MyNodeInfo_has_gps_tag 2 +#define MyNodeInfo_max_channels_tag 3 +#define MyNodeInfo_firmware_version_tag 4 +#define MyNodeInfo_error_code_tag 5 +#define MyNodeInfo_error_address_tag 6 +#define MyNodeInfo_error_count_tag 7 +#define MyNodeInfo_reboot_count_tag 8 +#define MyNodeInfo_bitrate_tag 9 +#define MyNodeInfo_message_timeout_msec_tag 10 +#define MyNodeInfo_min_app_version_tag 11 +#define MyNodeInfo_air_period_tx_tag 12 +#define MyNodeInfo_air_period_rx_tag 13 +#define MyNodeInfo_has_wifi_tag 14 +#define MyNodeInfo_channel_utilization_tag 15 +#define MyNodeInfo_air_util_tx_tag 16 +#define LogRecord_message_tag 1 +#define LogRecord_time_tag 2 +#define LogRecord_source_tag 3 +#define LogRecord_level_tag 4 +#define QueueStatus_res_tag 1 +#define QueueStatus_free_tag 2 +#define QueueStatus_maxlen_tag 3 +#define QueueStatus_mesh_packet_id_tag 4 +#define FromRadio_id_tag 1 +#define FromRadio_packet_tag 2 +#define FromRadio_my_info_tag 3 +#define FromRadio_node_info_tag 4 +#define FromRadio_config_tag 5 +#define FromRadio_log_record_tag 6 +#define FromRadio_config_complete_id_tag 7 +#define FromRadio_rebooted_tag 8 +#define FromRadio_moduleConfig_tag 9 +#define FromRadio_channel_tag 10 +#define FromRadio_queueStatus_tag 11 +#define FromRadio_xmodemPacket_tag 12 +#define ToRadio_packet_tag 1 +#define ToRadio_want_config_id_tag 3 +#define ToRadio_disconnect_tag 4 +#define ToRadio_xmodemPacket_tag 5 +#define Compressed_portnum_tag 1 +#define Compressed_data_tag 2 /* Struct field encoding specification for nanopb */ #define Position_FIELDLIST(X, a) \ @@ -1136,20 +1136,20 @@ extern const pb_msgdesc_t Compressed_msg; #define Compressed_fields &Compressed_msg /* Maximum encoded size of messages (where known) */ -#define Compressed_size 243 -#define Data_size 270 -#define FromRadio_size 330 -#define LogRecord_size 81 -#define MeshPacket_size 321 -#define MyNodeInfo_size 179 -#define NodeInfo_size 258 -#define Position_size 137 -#define QueueStatus_size 23 -#define RouteDiscovery_size 40 -#define Routing_size 42 -#define ToRadio_size 324 -#define User_size 77 -#define Waypoint_size 165 +#define Compressed_size 243 +#define Data_size 270 +#define FromRadio_size 330 +#define LogRecord_size 81 +#define MeshPacket_size 321 +#define MyNodeInfo_size 179 +#define NodeInfo_size 258 +#define Position_size 137 +#define QueueStatus_size 23 +#define RouteDiscovery_size 40 +#define Routing_size 42 +#define ToRadio_size 324 +#define User_size 77 +#define Waypoint_size 165 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/module_config.pb.c b/src/mesh/generated/meshtastic/module_config.pb.c similarity index 96% rename from src/mesh/generated/module_config.pb.c rename to src/mesh/generated/meshtastic/module_config.pb.c index eb22a5ec3..a67bcfcc9 100644 --- a/src/mesh/generated/module_config.pb.c +++ b/src/mesh/generated/meshtastic/module_config.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.7 */ -#include "module_config.pb.h" +#include "./module_config.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/src/mesh/generated/module_config.pb.h b/src/mesh/generated/meshtastic/module_config.pb.h similarity index 89% rename from src/mesh/generated/module_config.pb.h rename to src/mesh/generated/meshtastic/module_config.pb.h index bd4e90832..84914285f 100644 --- a/src/mesh/generated/module_config.pb.h +++ b/src/mesh/generated/meshtastic/module_config.pb.h @@ -1,8 +1,8 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.7 */ -#ifndef PB_MODULE_CONFIG_PB_H_INCLUDED -#define PB_MODULE_CONFIG_PB_H_INCLUDED +#ifndef PB_MESHTASTIC_MESHTASTIC_MODULE_CONFIG_PB_H_INCLUDED +#define PB_MESHTASTIC_MESHTASTIC_MODULE_CONFIG_PB_H_INCLUDED #include #if PB_PROTO_HEADER_VERSION != 40 @@ -317,49 +317,49 @@ extern "C" { /* Initializer values for message structs */ -#define ModuleConfig_init_default {0, {ModuleConfig_MQTTConfig_init_default}} -#define ModuleConfig_MQTTConfig_init_default {0, "", "", "", 0, 0} +#define ModuleConfig_init_default {0, {ModuleConfig_MQTTConfig_init_default}} +#define ModuleConfig_MQTTConfig_init_default {0, "", "", "", 0, 0} #define ModuleConfig_RemoteHardwareConfig_init_default {0} -#define ModuleConfig_AudioConfig_init_default {0, 0, _ModuleConfig_AudioConfig_Audio_Baud_MIN, 0, 0, 0, 0} -#define ModuleConfig_SerialConfig_init_default {0, 0, 0, 0, _ModuleConfig_SerialConfig_Serial_Baud_MIN, 0, _ModuleConfig_SerialConfig_Serial_Mode_MIN} +#define ModuleConfig_AudioConfig_init_default {0, 0, _ModuleConfig_AudioConfig_Audio_Baud_MIN, 0, 0, 0, 0} +#define ModuleConfig_SerialConfig_init_default {0, 0, 0, 0, _ModuleConfig_SerialConfig_Serial_Baud_MIN, 0, _ModuleConfig_SerialConfig_Serial_Mode_MIN} #define ModuleConfig_ExternalNotificationConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define ModuleConfig_StoreForwardConfig_init_default {0, 0, 0, 0, 0} #define ModuleConfig_RangeTestConfig_init_default {0, 0, 0} #define ModuleConfig_TelemetryConfig_init_default {0, 0, 0, 0, 0} #define ModuleConfig_CannedMessageConfig_init_default {0, 0, 0, 0, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, 0, 0, "", 0} -#define ModuleConfig_init_zero {0, {ModuleConfig_MQTTConfig_init_zero}} -#define ModuleConfig_MQTTConfig_init_zero {0, "", "", "", 0, 0} +#define ModuleConfig_init_zero {0, {ModuleConfig_MQTTConfig_init_zero}} +#define ModuleConfig_MQTTConfig_init_zero {0, "", "", "", 0, 0} #define ModuleConfig_RemoteHardwareConfig_init_zero {0} -#define ModuleConfig_AudioConfig_init_zero {0, 0, _ModuleConfig_AudioConfig_Audio_Baud_MIN, 0, 0, 0, 0} -#define ModuleConfig_SerialConfig_init_zero {0, 0, 0, 0, _ModuleConfig_SerialConfig_Serial_Baud_MIN, 0, _ModuleConfig_SerialConfig_Serial_Mode_MIN} +#define ModuleConfig_AudioConfig_init_zero {0, 0, _ModuleConfig_AudioConfig_Audio_Baud_MIN, 0, 0, 0, 0} +#define ModuleConfig_SerialConfig_init_zero {0, 0, 0, 0, _ModuleConfig_SerialConfig_Serial_Baud_MIN, 0, _ModuleConfig_SerialConfig_Serial_Mode_MIN} #define ModuleConfig_ExternalNotificationConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define ModuleConfig_StoreForwardConfig_init_zero {0, 0, 0, 0, 0} -#define ModuleConfig_RangeTestConfig_init_zero {0, 0, 0} -#define ModuleConfig_TelemetryConfig_init_zero {0, 0, 0, 0, 0} +#define ModuleConfig_RangeTestConfig_init_zero {0, 0, 0} +#define ModuleConfig_TelemetryConfig_init_zero {0, 0, 0, 0, 0} #define ModuleConfig_CannedMessageConfig_init_zero {0, 0, 0, 0, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, 0, 0, "", 0} /* Field tags (for use in manual encoding/decoding) */ -#define ModuleConfig_MQTTConfig_enabled_tag 1 -#define ModuleConfig_MQTTConfig_address_tag 2 -#define ModuleConfig_MQTTConfig_username_tag 3 -#define ModuleConfig_MQTTConfig_password_tag 4 +#define ModuleConfig_MQTTConfig_enabled_tag 1 +#define ModuleConfig_MQTTConfig_address_tag 2 +#define ModuleConfig_MQTTConfig_username_tag 3 +#define ModuleConfig_MQTTConfig_password_tag 4 #define ModuleConfig_MQTTConfig_encryption_enabled_tag 5 #define ModuleConfig_MQTTConfig_json_enabled_tag 6 #define ModuleConfig_RemoteHardwareConfig_enabled_tag 1 #define ModuleConfig_AudioConfig_codec2_enabled_tag 1 -#define ModuleConfig_AudioConfig_ptt_pin_tag 2 -#define ModuleConfig_AudioConfig_bitrate_tag 3 -#define ModuleConfig_AudioConfig_i2s_ws_tag 4 -#define ModuleConfig_AudioConfig_i2s_sd_tag 5 -#define ModuleConfig_AudioConfig_i2s_din_tag 6 -#define ModuleConfig_AudioConfig_i2s_sck_tag 7 -#define ModuleConfig_SerialConfig_enabled_tag 1 -#define ModuleConfig_SerialConfig_echo_tag 2 -#define ModuleConfig_SerialConfig_rxd_tag 3 -#define ModuleConfig_SerialConfig_txd_tag 4 -#define ModuleConfig_SerialConfig_baud_tag 5 -#define ModuleConfig_SerialConfig_timeout_tag 6 -#define ModuleConfig_SerialConfig_mode_tag 7 +#define ModuleConfig_AudioConfig_ptt_pin_tag 2 +#define ModuleConfig_AudioConfig_bitrate_tag 3 +#define ModuleConfig_AudioConfig_i2s_ws_tag 4 +#define ModuleConfig_AudioConfig_i2s_sd_tag 5 +#define ModuleConfig_AudioConfig_i2s_din_tag 6 +#define ModuleConfig_AudioConfig_i2s_sck_tag 7 +#define ModuleConfig_SerialConfig_enabled_tag 1 +#define ModuleConfig_SerialConfig_echo_tag 2 +#define ModuleConfig_SerialConfig_rxd_tag 3 +#define ModuleConfig_SerialConfig_txd_tag 4 +#define ModuleConfig_SerialConfig_baud_tag 5 +#define ModuleConfig_SerialConfig_timeout_tag 6 +#define ModuleConfig_SerialConfig_mode_tag 7 #define ModuleConfig_ExternalNotificationConfig_enabled_tag 1 #define ModuleConfig_ExternalNotificationConfig_output_ms_tag 2 #define ModuleConfig_ExternalNotificationConfig_output_tag 3 @@ -380,8 +380,8 @@ extern "C" { #define ModuleConfig_StoreForwardConfig_history_return_max_tag 4 #define ModuleConfig_StoreForwardConfig_history_return_window_tag 5 #define ModuleConfig_RangeTestConfig_enabled_tag 1 -#define ModuleConfig_RangeTestConfig_sender_tag 2 -#define ModuleConfig_RangeTestConfig_save_tag 3 +#define ModuleConfig_RangeTestConfig_sender_tag 2 +#define ModuleConfig_RangeTestConfig_save_tag 3 #define ModuleConfig_TelemetryConfig_device_update_interval_tag 1 #define ModuleConfig_TelemetryConfig_environment_update_interval_tag 2 #define ModuleConfig_TelemetryConfig_environment_measurement_enabled_tag 3 @@ -398,15 +398,15 @@ extern "C" { #define ModuleConfig_CannedMessageConfig_enabled_tag 9 #define ModuleConfig_CannedMessageConfig_allow_input_source_tag 10 #define ModuleConfig_CannedMessageConfig_send_bell_tag 11 -#define ModuleConfig_mqtt_tag 1 -#define ModuleConfig_serial_tag 2 -#define ModuleConfig_external_notification_tag 3 -#define ModuleConfig_store_forward_tag 4 -#define ModuleConfig_range_test_tag 5 -#define ModuleConfig_telemetry_tag 6 -#define ModuleConfig_canned_message_tag 7 -#define ModuleConfig_audio_tag 8 -#define ModuleConfig_remote_hardware_tag 9 +#define ModuleConfig_mqtt_tag 1 +#define ModuleConfig_serial_tag 2 +#define ModuleConfig_external_notification_tag 3 +#define ModuleConfig_store_forward_tag 4 +#define ModuleConfig_range_test_tag 5 +#define ModuleConfig_telemetry_tag 6 +#define ModuleConfig_canned_message_tag 7 +#define ModuleConfig_audio_tag 8 +#define ModuleConfig_remote_hardware_tag 9 /* Struct field encoding specification for nanopb */ #define ModuleConfig_FIELDLIST(X, a) \ @@ -550,16 +550,16 @@ extern const pb_msgdesc_t ModuleConfig_CannedMessageConfig_msg; #define ModuleConfig_CannedMessageConfig_fields &ModuleConfig_CannedMessageConfig_msg /* Maximum encoded size of messages (where known) */ -#define ModuleConfig_AudioConfig_size 19 -#define ModuleConfig_CannedMessageConfig_size 49 +#define ModuleConfig_AudioConfig_size 19 +#define ModuleConfig_CannedMessageConfig_size 49 #define ModuleConfig_ExternalNotificationConfig_size 40 -#define ModuleConfig_MQTTConfig_size 201 -#define ModuleConfig_RangeTestConfig_size 10 -#define ModuleConfig_RemoteHardwareConfig_size 2 -#define ModuleConfig_SerialConfig_size 26 -#define ModuleConfig_StoreForwardConfig_size 22 -#define ModuleConfig_TelemetryConfig_size 18 -#define ModuleConfig_size 204 +#define ModuleConfig_MQTTConfig_size 201 +#define ModuleConfig_RangeTestConfig_size 10 +#define ModuleConfig_RemoteHardwareConfig_size 2 +#define ModuleConfig_SerialConfig_size 26 +#define ModuleConfig_StoreForwardConfig_size 22 +#define ModuleConfig_TelemetryConfig_size 18 +#define ModuleConfig_size 204 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/mqtt.pb.c b/src/mesh/generated/meshtastic/mqtt.pb.c similarity index 91% rename from src/mesh/generated/mqtt.pb.c rename to src/mesh/generated/meshtastic/mqtt.pb.c index 9c2a7eb63..86a1e0075 100644 --- a/src/mesh/generated/mqtt.pb.c +++ b/src/mesh/generated/meshtastic/mqtt.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.7 */ -#include "mqtt.pb.h" +#include "./mqtt.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/src/mesh/generated/mqtt.pb.h b/src/mesh/generated/meshtastic/mqtt.pb.h similarity index 81% rename from src/mesh/generated/mqtt.pb.h rename to src/mesh/generated/meshtastic/mqtt.pb.h index 36de161cc..644a771bb 100644 --- a/src/mesh/generated/mqtt.pb.h +++ b/src/mesh/generated/meshtastic/mqtt.pb.h @@ -1,10 +1,10 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.7 */ -#ifndef PB_MQTT_PB_H_INCLUDED -#define PB_MQTT_PB_H_INCLUDED +#ifndef PB_MESHTASTIC_MESHTASTIC_MQTT_PB_H_INCLUDED +#define PB_MESHTASTIC_MESHTASTIC_MQTT_PB_H_INCLUDED #include -#include "mesh.pb.h" +#include "./mesh.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -29,13 +29,13 @@ extern "C" { #endif /* Initializer values for message structs */ -#define ServiceEnvelope_init_default {NULL, NULL, NULL} -#define ServiceEnvelope_init_zero {NULL, NULL, NULL} +#define ServiceEnvelope_init_default {NULL, NULL, NULL} +#define ServiceEnvelope_init_zero {NULL, NULL, NULL} /* Field tags (for use in manual encoding/decoding) */ -#define ServiceEnvelope_packet_tag 1 -#define ServiceEnvelope_channel_id_tag 2 -#define ServiceEnvelope_gateway_id_tag 3 +#define ServiceEnvelope_packet_tag 1 +#define ServiceEnvelope_channel_id_tag 2 +#define ServiceEnvelope_gateway_id_tag 3 /* Struct field encoding specification for nanopb */ #define ServiceEnvelope_FIELDLIST(X, a) \ diff --git a/src/mesh/generated/portnums.pb.c b/src/mesh/generated/meshtastic/portnums.pb.c similarity index 88% rename from src/mesh/generated/portnums.pb.c rename to src/mesh/generated/meshtastic/portnums.pb.c index 4e674aac5..663247bf8 100644 --- a/src/mesh/generated/portnums.pb.c +++ b/src/mesh/generated/meshtastic/portnums.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.7 */ -#include "portnums.pb.h" +#include "./portnums.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/src/mesh/generated/portnums.pb.h b/src/mesh/generated/meshtastic/portnums.pb.h similarity index 97% rename from src/mesh/generated/portnums.pb.h rename to src/mesh/generated/meshtastic/portnums.pb.h index 9e6a0b5b4..27d2ab498 100644 --- a/src/mesh/generated/portnums.pb.h +++ b/src/mesh/generated/meshtastic/portnums.pb.h @@ -1,8 +1,8 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.7 */ -#ifndef PB_PORTNUMS_PB_H_INCLUDED -#define PB_PORTNUMS_PB_H_INCLUDED +#ifndef PB_MESHTASTIC_MESHTASTIC_PORTNUMS_PB_H_INCLUDED +#define PB_MESHTASTIC_MESHTASTIC_PORTNUMS_PB_H_INCLUDED #include #if PB_PROTO_HEADER_VERSION != 40 diff --git a/src/mesh/generated/remote_hardware.pb.c b/src/mesh/generated/meshtastic/remote_hardware.pb.c similarity index 88% rename from src/mesh/generated/remote_hardware.pb.c rename to src/mesh/generated/meshtastic/remote_hardware.pb.c index de6c4dc4b..e33884659 100644 --- a/src/mesh/generated/remote_hardware.pb.c +++ b/src/mesh/generated/meshtastic/remote_hardware.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.7 */ -#include "remote_hardware.pb.h" +#include "./remote_hardware.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/src/mesh/generated/remote_hardware.pb.h b/src/mesh/generated/meshtastic/remote_hardware.pb.h similarity index 87% rename from src/mesh/generated/remote_hardware.pb.h rename to src/mesh/generated/meshtastic/remote_hardware.pb.h index 6c09809c5..b76dbe0bc 100644 --- a/src/mesh/generated/remote_hardware.pb.h +++ b/src/mesh/generated/meshtastic/remote_hardware.pb.h @@ -1,8 +1,8 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.7 */ -#ifndef PB_REMOTE_HARDWARE_PB_H_INCLUDED -#define PB_REMOTE_HARDWARE_PB_H_INCLUDED +#ifndef PB_MESHTASTIC_MESHTASTIC_REMOTE_HARDWARE_PB_H_INCLUDED +#define PB_MESHTASTIC_MESHTASTIC_REMOTE_HARDWARE_PB_H_INCLUDED #include #if PB_PROTO_HEADER_VERSION != 40 @@ -62,13 +62,13 @@ extern "C" { /* Initializer values for message structs */ -#define HardwareMessage_init_default {_HardwareMessage_Type_MIN, 0, 0} -#define HardwareMessage_init_zero {_HardwareMessage_Type_MIN, 0, 0} +#define HardwareMessage_init_default {_HardwareMessage_Type_MIN, 0, 0} +#define HardwareMessage_init_zero {_HardwareMessage_Type_MIN, 0, 0} /* Field tags (for use in manual encoding/decoding) */ -#define HardwareMessage_type_tag 1 -#define HardwareMessage_gpio_mask_tag 2 -#define HardwareMessage_gpio_value_tag 3 +#define HardwareMessage_type_tag 1 +#define HardwareMessage_gpio_mask_tag 2 +#define HardwareMessage_gpio_value_tag 3 /* Struct field encoding specification for nanopb */ #define HardwareMessage_FIELDLIST(X, a) \ @@ -84,7 +84,7 @@ extern const pb_msgdesc_t HardwareMessage_msg; #define HardwareMessage_fields &HardwareMessage_msg /* Maximum encoded size of messages (where known) */ -#define HardwareMessage_size 24 +#define HardwareMessage_size 24 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/rtttl.pb.c b/src/mesh/generated/meshtastic/rtttl.pb.c similarity index 91% rename from src/mesh/generated/rtttl.pb.c rename to src/mesh/generated/meshtastic/rtttl.pb.c index 960d1ebcd..5980cacf2 100644 --- a/src/mesh/generated/rtttl.pb.c +++ b/src/mesh/generated/meshtastic/rtttl.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.7 */ -#include "rtttl.pb.h" +#include "./rtttl.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/src/mesh/generated/rtttl.pb.h b/src/mesh/generated/meshtastic/rtttl.pb.h similarity index 79% rename from src/mesh/generated/rtttl.pb.h rename to src/mesh/generated/meshtastic/rtttl.pb.h index 7c4de8f73..8cca21f59 100644 --- a/src/mesh/generated/rtttl.pb.h +++ b/src/mesh/generated/meshtastic/rtttl.pb.h @@ -1,8 +1,8 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.7 */ -#ifndef PB_RTTTL_PB_H_INCLUDED -#define PB_RTTTL_PB_H_INCLUDED +#ifndef PB_MESHTASTIC_MESHTASTIC_RTTTL_PB_H_INCLUDED +#define PB_MESHTASTIC_MESHTASTIC_RTTTL_PB_H_INCLUDED #include #if PB_PROTO_HEADER_VERSION != 40 @@ -22,11 +22,11 @@ extern "C" { #endif /* Initializer values for message structs */ -#define RTTTLConfig_init_default {""} -#define RTTTLConfig_init_zero {""} +#define RTTTLConfig_init_default {""} +#define RTTTLConfig_init_zero {""} /* Field tags (for use in manual encoding/decoding) */ -#define RTTTLConfig_ringtone_tag 1 +#define RTTTLConfig_ringtone_tag 1 /* Struct field encoding specification for nanopb */ #define RTTTLConfig_FIELDLIST(X, a) \ @@ -40,7 +40,7 @@ extern const pb_msgdesc_t RTTTLConfig_msg; #define RTTTLConfig_fields &RTTTLConfig_msg /* Maximum encoded size of messages (where known) */ -#define RTTTLConfig_size 232 +#define RTTTLConfig_size 232 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/storeforward.pb.c b/src/mesh/generated/meshtastic/storeforward.pb.c similarity index 93% rename from src/mesh/generated/storeforward.pb.c rename to src/mesh/generated/meshtastic/storeforward.pb.c index 69db0e3bf..154e01db5 100644 --- a/src/mesh/generated/storeforward.pb.c +++ b/src/mesh/generated/meshtastic/storeforward.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.7 */ -#include "storeforward.pb.h" +#include "./storeforward.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/src/mesh/generated/storeforward.pb.h b/src/mesh/generated/meshtastic/storeforward.pb.h similarity index 83% rename from src/mesh/generated/storeforward.pb.h rename to src/mesh/generated/meshtastic/storeforward.pb.h index 0f0761949..75b06fc4a 100644 --- a/src/mesh/generated/storeforward.pb.h +++ b/src/mesh/generated/meshtastic/storeforward.pb.h @@ -1,8 +1,8 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.7 */ -#ifndef PB_STOREFORWARD_PB_H_INCLUDED -#define PB_STOREFORWARD_PB_H_INCLUDED +#ifndef PB_MESHTASTIC_MESHTASTIC_STOREFORWARD_PB_H_INCLUDED +#define PB_MESHTASTIC_MESHTASTIC_STOREFORWARD_PB_H_INCLUDED #include #if PB_PROTO_HEADER_VERSION != 40 @@ -120,35 +120,35 @@ extern "C" { /* Initializer values for message structs */ -#define StoreAndForward_init_default {_StoreAndForward_RequestResponse_MIN, 0, {StoreAndForward_Statistics_init_default}} -#define StoreAndForward_Statistics_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0} -#define StoreAndForward_History_init_default {0, 0, 0} -#define StoreAndForward_Heartbeat_init_default {0, 0} -#define StoreAndForward_init_zero {_StoreAndForward_RequestResponse_MIN, 0, {StoreAndForward_Statistics_init_zero}} -#define StoreAndForward_Statistics_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0} -#define StoreAndForward_History_init_zero {0, 0, 0} -#define StoreAndForward_Heartbeat_init_zero {0, 0} +#define StoreAndForward_init_default {_StoreAndForward_RequestResponse_MIN, 0, {StoreAndForward_Statistics_init_default}} +#define StoreAndForward_Statistics_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0} +#define StoreAndForward_History_init_default {0, 0, 0} +#define StoreAndForward_Heartbeat_init_default {0, 0} +#define StoreAndForward_init_zero {_StoreAndForward_RequestResponse_MIN, 0, {StoreAndForward_Statistics_init_zero}} +#define StoreAndForward_Statistics_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0} +#define StoreAndForward_History_init_zero {0, 0, 0} +#define StoreAndForward_Heartbeat_init_zero {0, 0} /* Field tags (for use in manual encoding/decoding) */ #define StoreAndForward_Statistics_messages_total_tag 1 #define StoreAndForward_Statistics_messages_saved_tag 2 #define StoreAndForward_Statistics_messages_max_tag 3 -#define StoreAndForward_Statistics_up_time_tag 4 -#define StoreAndForward_Statistics_requests_tag 5 +#define StoreAndForward_Statistics_up_time_tag 4 +#define StoreAndForward_Statistics_requests_tag 5 #define StoreAndForward_Statistics_requests_history_tag 6 #define StoreAndForward_Statistics_heartbeat_tag 7 #define StoreAndForward_Statistics_return_max_tag 8 #define StoreAndForward_Statistics_return_window_tag 9 #define StoreAndForward_History_history_messages_tag 1 -#define StoreAndForward_History_window_tag 2 +#define StoreAndForward_History_window_tag 2 #define StoreAndForward_History_last_request_tag 3 -#define StoreAndForward_Heartbeat_period_tag 1 -#define StoreAndForward_Heartbeat_secondary_tag 2 -#define StoreAndForward_rr_tag 1 -#define StoreAndForward_stats_tag 2 -#define StoreAndForward_history_tag 3 -#define StoreAndForward_heartbeat_tag 4 -#define StoreAndForward_empty_tag 5 +#define StoreAndForward_Heartbeat_period_tag 1 +#define StoreAndForward_Heartbeat_secondary_tag 2 +#define StoreAndForward_rr_tag 1 +#define StoreAndForward_stats_tag 2 +#define StoreAndForward_history_tag 3 +#define StoreAndForward_heartbeat_tag 4 +#define StoreAndForward_empty_tag 5 /* Struct field encoding specification for nanopb */ #define StoreAndForward_FIELDLIST(X, a) \ @@ -201,10 +201,10 @@ extern const pb_msgdesc_t StoreAndForward_Heartbeat_msg; #define StoreAndForward_Heartbeat_fields &StoreAndForward_Heartbeat_msg /* Maximum encoded size of messages (where known) */ -#define StoreAndForward_Heartbeat_size 12 -#define StoreAndForward_History_size 18 -#define StoreAndForward_Statistics_size 50 -#define StoreAndForward_size 54 +#define StoreAndForward_Heartbeat_size 12 +#define StoreAndForward_History_size 18 +#define StoreAndForward_Statistics_size 50 +#define StoreAndForward_size 54 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/telemetry.pb.c b/src/mesh/generated/meshtastic/telemetry.pb.c similarity index 92% rename from src/mesh/generated/telemetry.pb.c rename to src/mesh/generated/meshtastic/telemetry.pb.c index 50202f4d6..1446be188 100644 --- a/src/mesh/generated/telemetry.pb.c +++ b/src/mesh/generated/meshtastic/telemetry.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.7 */ -#include "telemetry.pb.h" +#include "./telemetry.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/src/mesh/generated/telemetry.pb.h b/src/mesh/generated/meshtastic/telemetry.pb.h similarity index 81% rename from src/mesh/generated/telemetry.pb.h rename to src/mesh/generated/meshtastic/telemetry.pb.h index e5c71a2b7..7d4bb02eb 100644 --- a/src/mesh/generated/telemetry.pb.h +++ b/src/mesh/generated/meshtastic/telemetry.pb.h @@ -1,8 +1,8 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.7 */ -#ifndef PB_TELEMETRY_PB_H_INCLUDED -#define PB_TELEMETRY_PB_H_INCLUDED +#ifndef PB_MESHTASTIC_MESHTASTIC_TELEMETRY_PB_H_INCLUDED +#define PB_MESHTASTIC_MESHTASTIC_TELEMETRY_PB_H_INCLUDED #include #if PB_PROTO_HEADER_VERSION != 40 @@ -101,27 +101,27 @@ extern "C" { /* Initializer values for message structs */ -#define DeviceMetrics_init_default {0, 0, 0, 0} -#define EnvironmentMetrics_init_default {0, 0, 0, 0, 0, 0} -#define Telemetry_init_default {0, 0, {DeviceMetrics_init_default}} -#define DeviceMetrics_init_zero {0, 0, 0, 0} -#define EnvironmentMetrics_init_zero {0, 0, 0, 0, 0, 0} -#define Telemetry_init_zero {0, 0, {DeviceMetrics_init_zero}} +#define DeviceMetrics_init_default {0, 0, 0, 0} +#define EnvironmentMetrics_init_default {0, 0, 0, 0, 0, 0} +#define Telemetry_init_default {0, 0, {DeviceMetrics_init_default}} +#define DeviceMetrics_init_zero {0, 0, 0, 0} +#define EnvironmentMetrics_init_zero {0, 0, 0, 0, 0, 0} +#define Telemetry_init_zero {0, 0, {DeviceMetrics_init_zero}} /* Field tags (for use in manual encoding/decoding) */ -#define DeviceMetrics_battery_level_tag 1 -#define DeviceMetrics_voltage_tag 2 -#define DeviceMetrics_channel_utilization_tag 3 -#define DeviceMetrics_air_util_tx_tag 4 -#define EnvironmentMetrics_temperature_tag 1 +#define DeviceMetrics_battery_level_tag 1 +#define DeviceMetrics_voltage_tag 2 +#define DeviceMetrics_channel_utilization_tag 3 +#define DeviceMetrics_air_util_tx_tag 4 +#define EnvironmentMetrics_temperature_tag 1 #define EnvironmentMetrics_relative_humidity_tag 2 #define EnvironmentMetrics_barometric_pressure_tag 3 -#define EnvironmentMetrics_gas_resistance_tag 4 -#define EnvironmentMetrics_voltage_tag 5 -#define EnvironmentMetrics_current_tag 6 -#define Telemetry_time_tag 1 -#define Telemetry_device_metrics_tag 2 -#define Telemetry_environment_metrics_tag 3 +#define EnvironmentMetrics_gas_resistance_tag 4 +#define EnvironmentMetrics_voltage_tag 5 +#define EnvironmentMetrics_current_tag 6 +#define Telemetry_time_tag 1 +#define Telemetry_device_metrics_tag 2 +#define Telemetry_environment_metrics_tag 3 /* Struct field encoding specification for nanopb */ #define DeviceMetrics_FIELDLIST(X, a) \ @@ -161,9 +161,9 @@ extern const pb_msgdesc_t Telemetry_msg; #define Telemetry_fields &Telemetry_msg /* Maximum encoded size of messages (where known) */ -#define DeviceMetrics_size 21 -#define EnvironmentMetrics_size 30 -#define Telemetry_size 37 +#define DeviceMetrics_size 21 +#define EnvironmentMetrics_size 30 +#define Telemetry_size 37 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/xmodem.pb.c b/src/mesh/generated/meshtastic/xmodem.pb.c similarity index 90% rename from src/mesh/generated/xmodem.pb.c rename to src/mesh/generated/meshtastic/xmodem.pb.c index f210380fe..f2b00401d 100644 --- a/src/mesh/generated/xmodem.pb.c +++ b/src/mesh/generated/meshtastic/xmodem.pb.c @@ -1,7 +1,7 @@ /* Automatically generated nanopb constant definitions */ /* Generated by nanopb-0.4.7 */ -#include "xmodem.pb.h" +#include "./xmodem.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. #endif diff --git a/src/mesh/generated/xmodem.pb.h b/src/mesh/generated/meshtastic/xmodem.pb.h similarity index 77% rename from src/mesh/generated/xmodem.pb.h rename to src/mesh/generated/meshtastic/xmodem.pb.h index 453c8ce7c..4994fa97b 100644 --- a/src/mesh/generated/xmodem.pb.h +++ b/src/mesh/generated/meshtastic/xmodem.pb.h @@ -1,8 +1,8 @@ /* Automatically generated nanopb header */ /* Generated by nanopb-0.4.7 */ -#ifndef PB_XMODEM_PB_H_INCLUDED -#define PB_XMODEM_PB_H_INCLUDED +#ifndef PB_MESHTASTIC_MESHTASTIC_XMODEM_PB_H_INCLUDED +#define PB_MESHTASTIC_MESHTASTIC_XMODEM_PB_H_INCLUDED #include #if PB_PROTO_HEADER_VERSION != 40 @@ -44,14 +44,14 @@ extern "C" { /* Initializer values for message structs */ -#define XModem_init_default {_XModem_Control_MIN, 0, 0, {0, {0}}} -#define XModem_init_zero {_XModem_Control_MIN, 0, 0, {0, {0}}} +#define XModem_init_default {_XModem_Control_MIN, 0, 0, {0, {0}}} +#define XModem_init_zero {_XModem_Control_MIN, 0, 0, {0, {0}}} /* Field tags (for use in manual encoding/decoding) */ -#define XModem_control_tag 1 -#define XModem_seq_tag 2 -#define XModem_crc16_tag 3 -#define XModem_buffer_tag 4 +#define XModem_control_tag 1 +#define XModem_seq_tag 2 +#define XModem_crc16_tag 3 +#define XModem_buffer_tag 4 /* Struct field encoding specification for nanopb */ #define XModem_FIELDLIST(X, a) \ @@ -68,7 +68,7 @@ extern const pb_msgdesc_t XModem_msg; #define XModem_fields &XModem_msg /* Maximum encoded size of messages (where known) */ -#define XModem_size 141 +#define XModem_size 141 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/mesh-pb-constants.h b/src/mesh/mesh-pb-constants.h index 59ccc9e16..aadfe1f54 100644 --- a/src/mesh/mesh-pb-constants.h +++ b/src/mesh/mesh-pb-constants.h @@ -1,9 +1,9 @@ #pragma once -#include "mesh/generated/mesh.pb.h" -#include "mesh/generated/localonly.pb.h" -#include "mesh/generated/deviceonly.pb.h" -#include "mesh/generated/admin.pb.h" +#include "mesh/generated/meshtastic/admin.pb.h" +#include "mesh/generated/meshtastic/deviceonly.pb.h" +#include "mesh/generated/meshtastic/localonly.pb.h" +#include "mesh/generated/meshtastic/mesh.pb.h" // this file defines constants which come from mesh.options @@ -11,8 +11,8 @@ #define member_size(type, member) sizeof(((type *)0)->member) /// max number of packets which can be waiting for delivery to android - note, this value comes from mesh.options protobuf -// FIXME - max_count is actually 32 but we save/load this as one long string of preencoded MeshPacket bytes - not a big array in RAM -// #define MAX_RX_TOPHONE (member_size(DeviceState, receive_queue) / member_size(DeviceState, receive_queue[0])) +// FIXME - max_count is actually 32 but we save/load this as one long string of preencoded MeshPacket bytes - not a big array in +// RAM #define MAX_RX_TOPHONE (member_size(DeviceState, receive_queue) / member_size(DeviceState, receive_queue[0])) #define MAX_RX_TOPHONE 32 /// max number of nodes allowed in the mesh @@ -36,7 +36,7 @@ bool writecb(pb_ostream_t *stream, const uint8_t *buf, size_t count); /** is_in_repeated is a macro/function that returns true if a specified word appears in a repeated protobuf array. * It relies on the following naming conventions from nanopb: - * + * * pb_size_t ignore_incoming_count; * uint32_t ignore_incoming[3]; */ diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 0bef684f2..ac13f273a 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -109,11 +109,11 @@ bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r) } case AdminMessage_reboot_ota_seconds_tag: { int32_t s = r->reboot_ota_seconds; -#ifdef ARCH_ESP32 +#ifdef ARCH_ESP32 if (BleOta::getOtaAppVersion().isEmpty()) { LOG_INFO("No OTA firmware available, scheduling regular reboot in %d seconds\n", s); screen->startRebootScreen(); - }else{ + } else { screen->startFirmwareUpdateScreen(); BleOta::switchToOtaApp(); LOG_INFO("Rebooting to OTA in %d seconds\n", s); @@ -141,7 +141,8 @@ bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r) nodeDB.factoryReset(); reboot(DEFAULT_REBOOT_SECONDS); break; - } case AdminMessage_nodedb_reset_tag: { + } + case AdminMessage_nodedb_reset_tag: { LOG_INFO("Initiating node-db reset\n"); nodeDB.resetNodes(); reboot(DEFAULT_REBOOT_SECONDS); @@ -179,7 +180,7 @@ bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r) } break; } - + // If asked for a response and it is not yet set, generate an 'ACK' response if (mp.decoded.want_response && !myReply) { myReply = allocErrorResponse(Routing_Error_NONE, &mp); @@ -213,7 +214,7 @@ void AdminModule::handleSetOwner(const User &o) changed = 1; licensed_changed = true; owner.is_licensed = o.is_licensed; - config.lora.override_duty_cycle = owner.is_licensed; // override duty cycle for licensed operators + config.lora.override_duty_cycle = owner.is_licensed; // override duty cycle for licensed operators } if (changed) { // If nothing really changed, don't broadcast on the network or write to flash @@ -228,106 +229,104 @@ void AdminModule::handleSetConfig(const Config &c) bool isRegionUnset = (config.lora.region == Config_LoRaConfig_RegionCode_UNSET); switch (c.which_payload_variant) { - case Config_device_tag: - LOG_INFO("Setting config: Device\n"); - config.has_device = true; - config.device = c.payload_variant.device; - // If we're setting router role for the first time, install its intervals - if (!isRouter && - c.payload_variant.device.role == Config_DeviceConfig_Role_ROUTER) { - nodeDB.initConfigIntervals(); - nodeDB.initModuleConfigIntervals(); - } - break; - case Config_position_tag: - LOG_INFO("Setting config: Position\n"); - config.has_position = true; - config.position = c.payload_variant.position; - // Save nodedb as well in case we got a fixed position packet - saveChanges(SEGMENT_DEVICESTATE, false); - break; - case Config_power_tag: - LOG_INFO("Setting config: Power\n"); - config.has_power = true; - config.power = c.payload_variant.power; - break; - case Config_network_tag: - LOG_INFO("Setting config: WiFi\n"); - config.has_network = true; - config.network = c.payload_variant.network; - break; - case Config_display_tag: - LOG_INFO("Setting config: Display\n"); - config.has_display = true; - config.display = c.payload_variant.display; - break; - case Config_lora_tag: - LOG_INFO("Setting config: LoRa\n"); - config.has_lora = true; - config.lora = c.payload_variant.lora; - if (isRegionUnset && - config.lora.region > Config_LoRaConfig_RegionCode_UNSET) { - config.lora.tx_enabled = true; - } - break; - case Config_bluetooth_tag: - LOG_INFO("Setting config: Bluetooth\n"); - config.has_bluetooth = true; - config.bluetooth = c.payload_variant.bluetooth; - break; + case Config_device_tag: + LOG_INFO("Setting config: Device\n"); + config.has_device = true; + config.device = c.payload_variant.device; + // If we're setting router role for the first time, install its intervals + if (!isRouter && c.payload_variant.device.role == Config_DeviceConfig_Role_ROUTER) { + nodeDB.initConfigIntervals(); + nodeDB.initModuleConfigIntervals(); + } + break; + case Config_position_tag: + LOG_INFO("Setting config: Position\n"); + config.has_position = true; + config.position = c.payload_variant.position; + // Save nodedb as well in case we got a fixed position packet + saveChanges(SEGMENT_DEVICESTATE, false); + break; + case Config_power_tag: + LOG_INFO("Setting config: Power\n"); + config.has_power = true; + config.power = c.payload_variant.power; + break; + case Config_network_tag: + LOG_INFO("Setting config: WiFi\n"); + config.has_network = true; + config.network = c.payload_variant.network; + break; + case Config_display_tag: + LOG_INFO("Setting config: Display\n"); + config.has_display = true; + config.display = c.payload_variant.display; + break; + case Config_lora_tag: + LOG_INFO("Setting config: LoRa\n"); + config.has_lora = true; + config.lora = c.payload_variant.lora; + if (isRegionUnset && config.lora.region > Config_LoRaConfig_RegionCode_UNSET) { + config.lora.tx_enabled = true; + } + break; + case Config_bluetooth_tag: + LOG_INFO("Setting config: Bluetooth\n"); + config.has_bluetooth = true; + config.bluetooth = c.payload_variant.bluetooth; + break; } - + saveChanges(SEGMENT_CONFIG); } void AdminModule::handleSetModuleConfig(const ModuleConfig &c) { switch (c.which_payload_variant) { - case ModuleConfig_mqtt_tag: - LOG_INFO("Setting module config: MQTT\n"); - moduleConfig.has_mqtt = true; - moduleConfig.mqtt = c.payload_variant.mqtt; - break; - case ModuleConfig_serial_tag: - LOG_INFO("Setting module config: Serial\n"); - moduleConfig.has_serial = true; - moduleConfig.serial = c.payload_variant.serial; - break; - case ModuleConfig_external_notification_tag: - LOG_INFO("Setting module config: External Notification\n"); - moduleConfig.has_external_notification = true; - moduleConfig.external_notification = c.payload_variant.external_notification; - break; - case ModuleConfig_store_forward_tag: - LOG_INFO("Setting module config: Store & Forward\n"); - moduleConfig.has_store_forward = true; - moduleConfig.store_forward = c.payload_variant.store_forward; - break; - case ModuleConfig_range_test_tag: - LOG_INFO("Setting module config: Range Test\n"); - moduleConfig.has_range_test = true; - moduleConfig.range_test = c.payload_variant.range_test; - break; - case ModuleConfig_telemetry_tag: - LOG_INFO("Setting module config: Telemetry\n"); - moduleConfig.has_telemetry = true; - moduleConfig.telemetry = c.payload_variant.telemetry; - break; - case ModuleConfig_canned_message_tag: - LOG_INFO("Setting module config: Canned Message\n"); - moduleConfig.has_canned_message = true; - moduleConfig.canned_message = c.payload_variant.canned_message; - break; - case ModuleConfig_audio_tag: - LOG_INFO("Setting module config: Audio\n"); - moduleConfig.has_audio = true; - moduleConfig.audio = c.payload_variant.audio; - break; - case ModuleConfig_remote_hardware_tag: - LOG_INFO("Setting module config: Remote Hardware\n"); - moduleConfig.has_remote_hardware = true; - moduleConfig.remote_hardware = c.payload_variant.remote_hardware; - break; + case ModuleConfig_mqtt_tag: + LOG_INFO("Setting module config: MQTT\n"); + moduleConfig.has_mqtt = true; + moduleConfig.mqtt = c.payload_variant.mqtt; + break; + case ModuleConfig_serial_tag: + LOG_INFO("Setting module config: Serial\n"); + moduleConfig.has_serial = true; + moduleConfig.serial = c.payload_variant.serial; + break; + case ModuleConfig_external_notification_tag: + LOG_INFO("Setting module config: External Notification\n"); + moduleConfig.has_external_notification = true; + moduleConfig.external_notification = c.payload_variant.external_notification; + break; + case ModuleConfig_store_forward_tag: + LOG_INFO("Setting module config: Store & Forward\n"); + moduleConfig.has_store_forward = true; + moduleConfig.store_forward = c.payload_variant.store_forward; + break; + case ModuleConfig_range_test_tag: + LOG_INFO("Setting module config: Range Test\n"); + moduleConfig.has_range_test = true; + moduleConfig.range_test = c.payload_variant.range_test; + break; + case ModuleConfig_telemetry_tag: + LOG_INFO("Setting module config: Telemetry\n"); + moduleConfig.has_telemetry = true; + moduleConfig.telemetry = c.payload_variant.telemetry; + break; + case ModuleConfig_canned_message_tag: + LOG_INFO("Setting module config: Canned Message\n"); + moduleConfig.has_canned_message = true; + moduleConfig.canned_message = c.payload_variant.canned_message; + break; + case ModuleConfig_audio_tag: + LOG_INFO("Setting module config: Audio\n"); + moduleConfig.has_audio = true; + moduleConfig.audio = c.payload_variant.audio; + break; + case ModuleConfig_remote_hardware_tag: + LOG_INFO("Setting module config: Remote Hardware\n"); + moduleConfig.has_remote_hardware = true; + moduleConfig.remote_hardware = c.payload_variant.remote_hardware; + break; } saveChanges(SEGMENT_MODULECONFIG); @@ -381,7 +380,8 @@ void AdminModule::handleGetConfig(const MeshPacket &req, const uint32_t configTy LOG_INFO("Getting config: Network\n"); res.get_config_response.which_payload_variant = Config_network_tag; res.get_config_response.payload_variant.network = config.network; - writeSecret(res.get_config_response.payload_variant.network.wifi_psk, sizeof(res.get_config_response.payload_variant.network.wifi_psk), config.network.wifi_psk); + writeSecret(res.get_config_response.payload_variant.network.wifi_psk, + sizeof(res.get_config_response.payload_variant.network.wifi_psk), config.network.wifi_psk); break; case AdminMessage_ConfigType_DISPLAY_CONFIG: LOG_INFO("Getting config: Display\n"); @@ -430,8 +430,7 @@ void AdminModule::handleGetModuleConfig(const MeshPacket &req, const uint32_t co case AdminMessage_ModuleConfigType_EXTNOTIF_CONFIG: LOG_INFO("Getting module config: External Notification\n"); res.get_module_config_response.which_payload_variant = ModuleConfig_external_notification_tag; - res.get_module_config_response.payload_variant.external_notification = - moduleConfig.external_notification; + res.get_module_config_response.payload_variant.external_notification = moduleConfig.external_notification; break; case AdminMessage_ModuleConfigType_STOREFORWARD_CONFIG: LOG_INFO("Getting module config: Store & Forward\n"); @@ -477,9 +476,10 @@ void AdminModule::handleGetModuleConfig(const MeshPacket &req, const uint32_t co } } -void AdminModule::handleGetDeviceMetadata(const MeshPacket &req) { +void AdminModule::handleGetDeviceMetadata(const MeshPacket &req) +{ AdminMessage r = AdminMessage_init_default; - + DeviceMetadata deviceMetadata; strncpy(deviceMetadata.firmware_version, myNodeInfo.firmware_version, 18); deviceMetadata.device_state_version = DEVICESTATE_CUR_VER; @@ -487,6 +487,8 @@ void AdminModule::handleGetDeviceMetadata(const MeshPacket &req) { deviceMetadata.hasBluetooth = HAS_BLUETOOTH; deviceMetadata.hasWifi = HAS_WIFI; deviceMetadata.hasEthernet = HAS_ETHERNET; + deviceMetadata.role = config.device.role; + deviceMetadata.position_flags = config.position.position_flags; r.get_device_metadata_response = deviceMetadata; r.which_payload_variant = AdminMessage_get_device_metadata_response_tag; @@ -504,14 +506,14 @@ void AdminModule::handleGetChannel(const MeshPacket &req, uint32_t channelIndex) } } -void AdminModule::reboot(int32_t seconds) +void AdminModule::reboot(int32_t seconds) { LOG_INFO("Rebooting in %d seconds\n", seconds); screen->startRebootScreen(); rebootAtMsec = (seconds < 0) ? 0 : (millis() + seconds * 1000); } -void AdminModule::saveChanges(int saveWhat, bool shouldReboot) +void AdminModule::saveChanges(int saveWhat, bool shouldReboot) { if (!hasOpenEditTransaction) { LOG_INFO("Saving changes to disk\n"); @@ -519,8 +521,7 @@ void AdminModule::saveChanges(int saveWhat, bool shouldReboot) } else { LOG_INFO("Delaying save of changes to disk until the open transaction is committed\n"); } - if (shouldReboot) - { + if (shouldReboot) { reboot(DEFAULT_REBOOT_SECONDS); } } diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 9e42f8467..5e1550893 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -2,10 +2,10 @@ #if HAS_SCREEN #include "CannedMessageModule.h" #include "FSCommon.h" -#include "NodeDB.h" #include "MeshService.h" +#include "NodeDB.h" #include "PowerFSM.h" // neede for button bypass -#include "mesh/generated/cannedmessages.pb.h" +#include "mesh/generated/meshtastic/cannedmessages.pb.h" #ifdef OLED_RU #include "graphics/fonts/OLEDDisplayFontsRU.h" @@ -149,10 +149,10 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event) this->lastTouchMillis = 0; validEvent = true; } - if ((event->inputEvent == static_cast(ModuleConfig_CannedMessageConfig_InputEventChar_BACK)) || + if ((event->inputEvent == static_cast(ModuleConfig_CannedMessageConfig_InputEventChar_BACK)) || (event->inputEvent == static_cast(ModuleConfig_CannedMessageConfig_InputEventChar_LEFT)) || (event->inputEvent == static_cast(ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT))) { - LOG_DEBUG("Canned message event (%x)\n",event->kbchar); + LOG_DEBUG("Canned message event (%x)\n", event->kbchar); if (this->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT) { // pass the pressed key this->payload = event->kbchar; @@ -163,7 +163,8 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event) if (event->inputEvent == static_cast(ANYKEY)) { LOG_DEBUG("Canned message event any key pressed\n"); // when inactive, this will switch to the freetext mode - if ((this->runState == CANNED_MESSAGE_RUN_STATE_INACTIVE) || (this->runState == CANNED_MESSAGE_RUN_STATE_ACTIVE) || (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED)) { + if ((this->runState == CANNED_MESSAGE_RUN_STATE_INACTIVE) || (this->runState == CANNED_MESSAGE_RUN_STATE_ACTIVE) || + (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED)) { this->runState = CANNED_MESSAGE_RUN_STATE_FREETEXT; } // pass the pressed key @@ -176,7 +177,7 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event) // this will send the text immediately on matrix press this->runState = CANNED_MESSAGE_RUN_STATE_ACTION_SELECT; this->payload = MATRIXKEY; - this->currentMessageIndex = event->kbchar -1; + this->currentMessageIndex = event->kbchar - 1; this->lastTouchMillis = millis(); validEvent = true; } @@ -224,7 +225,8 @@ int32_t CannedMessageModule::runOnce() this->cursor = 0; this->destSelect = false; this->notifyObservers(&e); - } else if (((this->runState == CANNED_MESSAGE_RUN_STATE_ACTIVE) || (this->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT)) && ((millis() - this->lastTouchMillis) > INACTIVATE_AFTER_MS)) { + } else if (((this->runState == CANNED_MESSAGE_RUN_STATE_ACTIVE) || (this->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT)) && + ((millis() - this->lastTouchMillis) > INACTIVATE_AFTER_MS)) { // Reset module LOG_DEBUG("Reset due to lack of activity.\n"); e.frameChanged = true; @@ -245,7 +247,7 @@ int32_t CannedMessageModule::runOnce() } } else { if ((this->messagesCount > this->currentMessageIndex) && (strlen(this->messages[this->currentMessageIndex]) > 0)) { - if(strcmp (this->messages[this->currentMessageIndex], "~") == 0) { + if (strcmp(this->messages[this->currentMessageIndex], "~") == 0) { powerFSM.trigger(EVENT_PRESS); return INT32_MAX; } else { @@ -264,7 +266,7 @@ int32_t CannedMessageModule::runOnce() this->destSelect = false; this->notifyObservers(&e); return 2000; - } else if ((this->runState != CANNED_MESSAGE_RUN_STATE_FREETEXT) && (this->currentMessageIndex == -1)) { + } else if ((this->runState != CANNED_MESSAGE_RUN_STATE_FREETEXT) && (this->currentMessageIndex == -1)) { this->currentMessageIndex = 0; LOG_DEBUG("First touch (%d):%s\n", this->currentMessageIndex, this->getCurrentMessage()); e.frameChanged = true; @@ -290,81 +292,81 @@ int32_t CannedMessageModule::runOnce() } else if (this->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT) { e.frameChanged = true; switch (this->payload) { - case 0xb4: // left - if (this->destSelect){ - size_t numNodes = nodeDB.getNumNodes(); - if(this->dest == NODENUM_BROADCAST) { - this->dest = nodeDB.getNodeNum(); - } - for (unsigned int i = 0; i < numNodes; i++) { - if (nodeDB.getNodeByIndex(i)->num == this->dest) { - this->dest = (i > 0) ? nodeDB.getNodeByIndex(i-1)->num : nodeDB.getNodeByIndex(numNodes-1)->num; - break; - } - } - if(this->dest == nodeDB.getNodeNum()) { - this->dest = NODENUM_BROADCAST; - } - }else{ - if (this->cursor > 0) { - this->cursor--; + case 0xb4: // left + if (this->destSelect) { + size_t numNodes = nodeDB.getNumNodes(); + if (this->dest == NODENUM_BROADCAST) { + this->dest = nodeDB.getNodeNum(); + } + for (unsigned int i = 0; i < numNodes; i++) { + if (nodeDB.getNodeByIndex(i)->num == this->dest) { + this->dest = (i > 0) ? nodeDB.getNodeByIndex(i - 1)->num : nodeDB.getNodeByIndex(numNodes - 1)->num; + break; } } - break; - case 0xb7: // right - if (this->destSelect){ - size_t numNodes = nodeDB.getNumNodes(); - if(this->dest == NODENUM_BROADCAST) { - this->dest = nodeDB.getNodeNum(); - } - for (unsigned int i = 0; i < numNodes; i++) { - if (nodeDB.getNodeByIndex(i)->num == this->dest) { - this->dest = (i < numNodes-1) ? nodeDB.getNodeByIndex(i+1)->num : nodeDB.getNodeByIndex(0)->num; - break; - } - } - if(this->dest == nodeDB.getNodeNum()) { - this->dest = NODENUM_BROADCAST; - } - }else{ - if (this->cursor < this->freetext.length()) { - this->cursor++; - } + if (this->dest == nodeDB.getNodeNum()) { + this->dest = NODENUM_BROADCAST; } - break; - case 0x08: // backspace - if (this->freetext.length() > 0) { - if(this->cursor == this->freetext.length()) { - this->freetext = this->freetext.substring(0, this->freetext.length() - 1); - } else { - this->freetext = this->freetext.substring(0, this->cursor - 1) + this->freetext.substring(this->cursor, this->freetext.length()); - } + } else { + if (this->cursor > 0) { this->cursor--; } - break; - case 0x09: // tab - if(this->destSelect) { - this->destSelect = false; + } + break; + case 0xb7: // right + if (this->destSelect) { + size_t numNodes = nodeDB.getNumNodes(); + if (this->dest == NODENUM_BROADCAST) { + this->dest = nodeDB.getNodeNum(); + } + for (unsigned int i = 0; i < numNodes; i++) { + if (nodeDB.getNodeByIndex(i)->num == this->dest) { + this->dest = (i < numNodes - 1) ? nodeDB.getNodeByIndex(i + 1)->num : nodeDB.getNodeByIndex(0)->num; + break; + } + } + if (this->dest == nodeDB.getNodeNum()) { + this->dest = NODENUM_BROADCAST; + } + } else { + if (this->cursor < this->freetext.length()) { + this->cursor++; + } + } + break; + case 0x08: // backspace + if (this->freetext.length() > 0) { + if (this->cursor == this->freetext.length()) { + this->freetext = this->freetext.substring(0, this->freetext.length() - 1); } else { - this->destSelect = true; + this->freetext = this->freetext.substring(0, this->cursor - 1) + + this->freetext.substring(this->cursor, this->freetext.length()); } - break; - default: - if(this->cursor == this->freetext.length()) { - this->freetext += this->payload; - } else { - this->freetext = this->freetext.substring(0, this->cursor) - + this->payload - + this->freetext.substring(this->cursor); - } - this->cursor += 1; - if (this->freetext.length() > Constants_DATA_PAYLOAD_LEN) { - this->cursor = Constants_DATA_PAYLOAD_LEN; - this->freetext = this->freetext.substring(0, Constants_DATA_PAYLOAD_LEN); - } - break; + this->cursor--; + } + break; + case 0x09: // tab + if (this->destSelect) { + this->destSelect = false; + } else { + this->destSelect = true; + } + break; + default: + if (this->cursor == this->freetext.length()) { + this->freetext += this->payload; + } else { + this->freetext = + this->freetext.substring(0, this->cursor) + this->payload + this->freetext.substring(this->cursor); + } + this->cursor += 1; + if (this->freetext.length() > Constants_DATA_PAYLOAD_LEN) { + this->cursor = Constants_DATA_PAYLOAD_LEN; + this->freetext = this->freetext.substring(0, Constants_DATA_PAYLOAD_LEN); + } + break; } - + this->lastTouchMillis = millis(); this->notifyObservers(&e); return INACTIVATE_AFTER_MS; @@ -376,7 +378,7 @@ int32_t CannedMessageModule::runOnce() return INACTIVATE_AFTER_MS; } - return INT32_MAX; + return INT32_MAX; } const char *CannedMessageModule::getCurrentMessage() @@ -391,14 +393,15 @@ const char *CannedMessageModule::getNextMessage() { return this->messages[this->getNextIndex()]; } -const char* CannedMessageModule::getNodeName(NodeNum node) { - if (node == NODENUM_BROADCAST){ +const char *CannedMessageModule::getNodeName(NodeNum node) +{ + if (node == NODENUM_BROADCAST) { return "Broadcast"; - }else{ + } else { NodeInfo *info = nodeDB.getNode(node); - if(info != NULL) { + if (info != NULL) { return info->user.long_name; - }else{ + } else { return "Unknown"; } } @@ -444,7 +447,7 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st display->setTextAlignment(TEXT_ALIGN_LEFT); display->setFont(FONT_SMALL); display->drawString(10 + x, 0 + y + FONT_HEIGHT_SMALL, "Canned Message\nModule disabled."); - }else if (cannedMessageModule->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT) { + } else if (cannedMessageModule->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT) { display->setTextAlignment(TEXT_ALIGN_LEFT); display->setFont(FONT_SMALL); if (this->destSelect) { @@ -460,7 +463,9 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st display->drawString(x + display->getWidth() - display->getStringWidth(buffer) - 1, y + 0, buffer); } display->setColor(WHITE); - display->drawStringMaxWidth(0 + x, 0 + y + FONT_HEIGHT_SMALL, x + display->getWidth(), cannedMessageModule->drawWithCursor(cannedMessageModule->freetext, cannedMessageModule->cursor)); + display->drawStringMaxWidth( + 0 + x, 0 + y + FONT_HEIGHT_SMALL, x + display->getWidth(), + cannedMessageModule->drawWithCursor(cannedMessageModule->freetext, cannedMessageModule->cursor)); } else { if (this->messagesCount > 0) { display->setTextAlignment(TEXT_ALIGN_LEFT); @@ -479,7 +484,7 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st void CannedMessageModule::loadProtoForModule() { if (!nodeDB.loadProto(cannedMessagesConfigFile, CannedMessageModuleConfig_size, sizeof(CannedMessageModuleConfig), - &CannedMessageModuleConfig_msg, &cannedMessageModuleConfig)) { + &CannedMessageModuleConfig_msg, &cannedMessageModuleConfig)) { installDefaultCannedMessageModuleConfig(); } } @@ -498,8 +503,8 @@ bool CannedMessageModule::saveProtoForModule() FS.mkdir("/prefs"); #endif - okay &= nodeDB.saveProto(cannedMessagesConfigFile, CannedMessageModuleConfig_size, - &CannedMessageModuleConfig_msg, &cannedMessageModuleConfig); + okay &= nodeDB.saveProto(cannedMessagesConfigFile, CannedMessageModuleConfig_size, &CannedMessageModuleConfig_msg, + &cannedMessageModuleConfig); return okay; } @@ -549,13 +554,13 @@ AdminMessageHandleResult CannedMessageModule::handleAdminMessageForModule(const void CannedMessageModule::handleGetCannedMessageModuleMessages(const MeshPacket &req, AdminMessage *response) { LOG_DEBUG("*** handleGetCannedMessageModuleMessages\n"); - if(req.decoded.want_response) { + if (req.decoded.want_response) { response->which_payload_variant = AdminMessage_get_canned_message_module_messages_response_tag; - strncpy(response->get_canned_message_module_messages_response, cannedMessageModuleConfig.messages, sizeof(response->get_canned_message_module_messages_response)); + strncpy(response->get_canned_message_module_messages_response, cannedMessageModuleConfig.messages, + sizeof(response->get_canned_message_module_messages_response)); } // Don't send anything if not instructed to. Better than asserting. } - void CannedMessageModule::handleSetCannedMessageModuleMessages(const char *from_msg) { int changed = 0; @@ -573,9 +578,7 @@ void CannedMessageModule::handleSetCannedMessageModuleMessages(const char *from_ String CannedMessageModule::drawWithCursor(String text, int cursor) { - String result = text.substring(0, cursor) - + "_" - + text.substring(cursor); + String result = text.substring(0, cursor) + "_" + text.substring(cursor); return result; } diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 3f2137ec8..1e379b65c 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -5,7 +5,7 @@ #include "Router.h" #include "buzz/buzz.h" #include "configuration.h" -#include "mesh/generated/rtttl.pb.h" +#include "mesh/generated/meshtastic/rtttl.pb.h" #include #ifndef PIN_BUZZER @@ -58,19 +58,19 @@ int32_t ExternalNotificationModule::runOnce() // If the output is turned on, turn it back off after the given period of time. if (isNagging) { - if (externalTurnedOn[0] + (moduleConfig.external_notification.output_ms - ? moduleConfig.external_notification.output_ms - : EXT_NOTIFICATION_MODULE_OUTPUT_MS) < millis()) { + if (externalTurnedOn[0] + (moduleConfig.external_notification.output_ms ? moduleConfig.external_notification.output_ms + : EXT_NOTIFICATION_MODULE_OUTPUT_MS) < + millis()) { getExternal(0) ? setExternalOff(0) : setExternalOn(0); } - if (externalTurnedOn[1] + (moduleConfig.external_notification.output_ms - ? moduleConfig.external_notification.output_ms - : EXT_NOTIFICATION_MODULE_OUTPUT_MS) < millis()) { + if (externalTurnedOn[1] + (moduleConfig.external_notification.output_ms ? moduleConfig.external_notification.output_ms + : EXT_NOTIFICATION_MODULE_OUTPUT_MS) < + millis()) { getExternal(1) ? setExternalOff(1) : setExternalOn(1); } - if (externalTurnedOn[2] + (moduleConfig.external_notification.output_ms - ? moduleConfig.external_notification.output_ms - : EXT_NOTIFICATION_MODULE_OUTPUT_MS) < millis()) { + if (externalTurnedOn[2] + (moduleConfig.external_notification.output_ms ? moduleConfig.external_notification.output_ms + : EXT_NOTIFICATION_MODULE_OUTPUT_MS) < + millis()) { getExternal(2) ? setExternalOff(2) : setExternalOn(2); } } @@ -93,18 +93,18 @@ void ExternalNotificationModule::setExternalOn(uint8_t index) externalCurrentState[index] = 1; externalTurnedOn[index] = millis(); - switch(index) { - case 1: - if(moduleConfig.external_notification.output_vibra) - digitalWrite(moduleConfig.external_notification.output_vibra, true); - break; - case 2: - if(moduleConfig.external_notification.output_buzzer) - digitalWrite(moduleConfig.external_notification.output_buzzer, true); - break; - default: - digitalWrite(output, (moduleConfig.external_notification.active ? true : false)); - break; + switch (index) { + case 1: + if (moduleConfig.external_notification.output_vibra) + digitalWrite(moduleConfig.external_notification.output_vibra, true); + break; + case 2: + if (moduleConfig.external_notification.output_buzzer) + digitalWrite(moduleConfig.external_notification.output_buzzer, true); + break; + default: + digitalWrite(output, (moduleConfig.external_notification.active ? true : false)); + break; } } @@ -113,18 +113,18 @@ void ExternalNotificationModule::setExternalOff(uint8_t index) externalCurrentState[index] = 0; externalTurnedOn[index] = millis(); - switch(index) { - case 1: - if(moduleConfig.external_notification.output_vibra) - digitalWrite(moduleConfig.external_notification.output_vibra, false); - break; - case 2: - if(moduleConfig.external_notification.output_buzzer) - digitalWrite(moduleConfig.external_notification.output_buzzer, false); - break; - default: - digitalWrite(output, (moduleConfig.external_notification.active ? false : true)); - break; + switch (index) { + case 1: + if (moduleConfig.external_notification.output_vibra) + digitalWrite(moduleConfig.external_notification.output_vibra, false); + break; + case 2: + if (moduleConfig.external_notification.output_buzzer) + digitalWrite(moduleConfig.external_notification.output_buzzer, false); + break; + default: + digitalWrite(output, (moduleConfig.external_notification.active ? false : true)); + break; } } @@ -133,7 +133,8 @@ bool ExternalNotificationModule::getExternal(uint8_t index) return externalCurrentState[index]; } -void ExternalNotificationModule::stopNow() { +void ExternalNotificationModule::stopNow() +{ rtttl::stop(); nagCycleCutoff = 1; // small value isNagging = false; @@ -161,40 +162,39 @@ ExternalNotificationModule::ExternalNotificationModule() // moduleConfig.external_notification.output_buzzer = 10; // RAK4631 IO6 // moduleConfig.external_notification.output_vibra = 28; // RAK4631 IO7 // moduleConfig.external_notification.nag_timeout = 300; - + if (moduleConfig.external_notification.enabled) { if (!nodeDB.loadProto(rtttlConfigFile, RTTTLConfig_size, sizeof(RTTTLConfig), &RTTTLConfig_msg, &rtttlConfig)) { memset(rtttlConfig.ringtone, 0, sizeof(rtttlConfig.ringtone)); - strncpy(rtttlConfig.ringtone, "a:d=8,o=5,b=125:4d#6,a#,2d#6,16p,g#,4a#,4d#.,p,16g,16a#,d#6,a#,f6,2d#6,16p,c#.6,16c6,16a#,g#.,2a#", sizeof(rtttlConfig.ringtone)); + strncpy(rtttlConfig.ringtone, + "a:d=8,o=5,b=125:4d#6,a#,2d#6,16p,g#,4a#,4d#.,p,16g,16a#,d#6,a#,f6,2d#6,16p,c#.6,16c6,16a#,g#.,2a#", + sizeof(rtttlConfig.ringtone)); } LOG_INFO("Initializing External Notification Module\n"); - output = moduleConfig.external_notification.output - ? moduleConfig.external_notification.output - : EXT_NOTIFICATION_MODULE_OUTPUT; + output = moduleConfig.external_notification.output ? moduleConfig.external_notification.output + : EXT_NOTIFICATION_MODULE_OUTPUT; // Set the direction of a pin LOG_INFO("Using Pin %i in digital mode\n", output); pinMode(output, OUTPUT); setExternalOff(0); externalTurnedOn[0] = 0; - if(moduleConfig.external_notification.output_vibra) { + if (moduleConfig.external_notification.output_vibra) { LOG_INFO("Using Pin %i for vibra motor\n", moduleConfig.external_notification.output_vibra); pinMode(moduleConfig.external_notification.output_vibra, OUTPUT); setExternalOff(1); externalTurnedOn[1] = 0; } - if(moduleConfig.external_notification.output_buzzer) { + if (moduleConfig.external_notification.output_buzzer) { if (!moduleConfig.external_notification.use_pwm) { LOG_INFO("Using Pin %i for buzzer\n", moduleConfig.external_notification.output_buzzer); pinMode(moduleConfig.external_notification.output_buzzer, OUTPUT); setExternalOff(2); externalTurnedOn[2] = 0; } else { - config.device.buzzer_gpio = config.device.buzzer_gpio - ? config.device.buzzer_gpio - : PIN_BUZZER; + config.device.buzzer_gpio = config.device.buzzer_gpio ? config.device.buzzer_gpio : PIN_BUZZER; // in PWM Mode we force the buzzer pin if it is set LOG_INFO("Using Pin %i in PWM mode\n", config.device.buzzer_gpio); } @@ -274,7 +274,6 @@ ProcessMessage ExternalNotificationModule::handleReceived(const MeshPacket &mp) } } - if (moduleConfig.external_notification.alert_message_vibra) { LOG_INFO("externalNotificationModule - Notification Module (Vibra)\n"); isNagging = true; @@ -300,7 +299,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const MeshPacket &mp) nagCycleCutoff = millis() + moduleConfig.external_notification.output_ms; } } - + setIntervalFromNow(0); // run once so we know if we should do something } @@ -320,7 +319,8 @@ ProcessMessage ExternalNotificationModule::handleReceived(const MeshPacket &mp) * @return AdminMessageHandleResult HANDLED if message was handled * HANDLED_WITH_RESULT if a result is also prepared. */ -AdminMessageHandleResult ExternalNotificationModule::handleAdminMessageForModule(const MeshPacket &mp, AdminMessage *request, AdminMessage *response) +AdminMessageHandleResult ExternalNotificationModule::handleAdminMessageForModule(const MeshPacket &mp, AdminMessage *request, + AdminMessage *response) { AdminMessageHandleResult result; @@ -347,13 +347,12 @@ AdminMessageHandleResult ExternalNotificationModule::handleAdminMessageForModule void ExternalNotificationModule::handleGetRingtone(const MeshPacket &req, AdminMessage *response) { LOG_INFO("*** handleGetRingtone\n"); - if(req.decoded.want_response) { + if (req.decoded.want_response) { response->which_payload_variant = AdminMessage_get_ringtone_response_tag; strncpy(response->get_ringtone_response, rtttlConfig.ringtone, sizeof(response->get_ringtone_response)); } // Don't send anything if not instructed to. Better than asserting. } - void ExternalNotificationModule::handleSetRingtone(const char *from_msg) { int changed = 0; diff --git a/src/modules/RemoteHardwareModule.h b/src/modules/RemoteHardwareModule.h index e9c7794fb..69733a87d 100644 --- a/src/modules/RemoteHardwareModule.h +++ b/src/modules/RemoteHardwareModule.h @@ -1,7 +1,7 @@ #pragma once #include "ProtobufModule.h" -#include "mesh/generated/remote_hardware.pb.h" #include "concurrency/OSThread.h" +#include "mesh/generated/meshtastic/remote_hardware.pb.h" /** * A module that provides easy low-level remote access to device hardware. @@ -9,13 +9,14 @@ class RemoteHardwareModule : public ProtobufModule, private concurrency::OSThread { /// The current set of GPIOs we've been asked to watch for changes - uint64_t watchGpios = 0; + uint64_t watchGpios = 0; /// The previously read value of watched pins uint64_t previousWatch = 0; /// The timestamp of our last watch event (we throttle watches to 1 change every 30 seconds) uint32_t lastWatchMsec = 0; + public: /** Constructor * name is for debugging output @@ -32,7 +33,7 @@ class RemoteHardwareModule : public ProtobufModule, private con /** * Periodically read the gpios we have been asked to WATCH, if they have changed, * broadcast a message with the change information. - * + * * The method that will be called each time our thread gets a chance to run * * Returns desired period for next invocation (or RUN_SAME for no change) diff --git a/src/modules/Telemetry/DeviceTelemetry.cpp b/src/modules/Telemetry/DeviceTelemetry.cpp index 5f96661e5..3821ea445 100644 --- a/src/modules/Telemetry/DeviceTelemetry.cpp +++ b/src/modules/Telemetry/DeviceTelemetry.cpp @@ -1,5 +1,5 @@ #include "DeviceTelemetry.h" -#include "../mesh/generated/telemetry.pb.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" #include "MeshService.h" #include "NodeDB.h" #include "PowerFSM.h" @@ -9,13 +9,12 @@ #include "main.h" #include #include -#include "MeshService.h" int32_t DeviceTelemetryModule::runOnce() { uint32_t now = millis(); - if ((lastSentToMesh == 0 || - (now - lastSentToMesh) >= getConfiguredOrDefaultMs(moduleConfig.telemetry.device_update_interval)) && + if ((lastSentToMesh == 0 || + (now - lastSentToMesh) >= getConfiguredOrDefaultMs(moduleConfig.telemetry.device_update_interval)) && airTime->isTxAllowedChannelUtil() && airTime->isTxAllowedAirUtil()) { sendTelemetry(); lastSentToMesh = now; @@ -31,13 +30,10 @@ bool DeviceTelemetryModule::handleReceivedProtobuf(const MeshPacket &mp, Telemet { if (t->which_variant == Telemetry_device_metrics_tag) { const char *sender = getSenderShortName(mp); - - LOG_INFO("(Received from %s): air_util_tx=%f, channel_utilization=%f, battery_level=%i, voltage=%f\n", - sender, - t->variant.device_metrics.air_util_tx, - t->variant.device_metrics.channel_utilization, - t->variant.device_metrics.battery_level, - t->variant.device_metrics.voltage); + + LOG_INFO("(Received from %s): air_util_tx=%f, channel_utilization=%f, battery_level=%i, voltage=%f\n", sender, + t->variant.device_metrics.air_util_tx, t->variant.device_metrics.channel_utilization, + t->variant.device_metrics.battery_level, t->variant.device_metrics.voltage); lastMeasurementPacket = packetPool.allocCopy(mp); @@ -58,11 +54,9 @@ bool DeviceTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) t.variant.device_metrics.channel_utilization = myNodeInfo.channel_utilization; t.variant.device_metrics.voltage = powerStatus->getBatteryVoltageMv() / 1000.0; - LOG_INFO("(Sending): air_util_tx=%f, channel_utilization=%f, battery_level=%i, voltage=%f\n", - t.variant.device_metrics.air_util_tx, - t.variant.device_metrics.channel_utilization, - t.variant.device_metrics.battery_level, - t.variant.device_metrics.voltage); + LOG_INFO("(Sending): air_util_tx=%f, channel_utilization=%f, battery_level=%i, voltage=%f\n", + t.variant.device_metrics.air_util_tx, t.variant.device_metrics.channel_utilization, + t.variant.device_metrics.battery_level, t.variant.device_metrics.voltage); MeshPacket *p = allocDataProtobuf(t); p->to = dest; diff --git a/src/modules/Telemetry/DeviceTelemetry.h b/src/modules/Telemetry/DeviceTelemetry.h index 0fb33ceee..11506c71f 100644 --- a/src/modules/Telemetry/DeviceTelemetry.h +++ b/src/modules/Telemetry/DeviceTelemetry.h @@ -1,5 +1,5 @@ #pragma once -#include "../mesh/generated/telemetry.pb.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" #include "NodeDB.h" #include "ProtobufModule.h" #include @@ -11,8 +11,8 @@ class DeviceTelemetryModule : private concurrency::OSThread, public ProtobufModu DeviceTelemetryModule() : concurrency::OSThread("DeviceTelemetryModule"), ProtobufModule("DeviceTelemetry", PortNum_TELEMETRY_APP, &Telemetry_msg) { - lastMeasurementPacket = nullptr; - setIntervalFromNow(10 * 1000); + lastMeasurementPacket = nullptr; + setIntervalFromNow(10 * 1000); } virtual bool wantUIFrame() { return false; } diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index 2a29405d3..dce243b83 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -1,5 +1,5 @@ #include "EnvironmentTelemetry.h" -#include "../mesh/generated/telemetry.pb.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" #include "MeshService.h" #include "NodeDB.h" #include "PowerFSM.h" @@ -9,18 +9,17 @@ #include "main.h" #include #include -#include "MeshService.h" // Sensors -#include "Sensor/BMP280Sensor.h" #include "Sensor/BME280Sensor.h" #include "Sensor/BME680Sensor.h" -#include "Sensor/MCP9808Sensor.h" -#include "Sensor/INA260Sensor.h" +#include "Sensor/BMP280Sensor.h" #include "Sensor/INA219Sensor.h" -#include "Sensor/SHTC3Sensor.h" +#include "Sensor/INA260Sensor.h" #include "Sensor/LPS22HBSensor.h" +#include "Sensor/MCP9808Sensor.h" #include "Sensor/SHT31Sensor.h" +#include "Sensor/SHTC3Sensor.h" BMP280Sensor bmp280Sensor; BME280Sensor bme280Sensor; @@ -59,13 +58,12 @@ int32_t EnvironmentTelemetryModule::runOnce() Uncomment the preferences below if you want to use the module without having to configure it from the PythonAPI or WebUI. */ - + // moduleConfig.telemetry.environment_measurement_enabled = 1; // moduleConfig.telemetry.environment_screen_enabled = 1; // moduleConfig.telemetry.environment_update_interval = 45; - if (!(moduleConfig.telemetry.environment_measurement_enabled || - moduleConfig.telemetry.environment_screen_enabled)) { + if (!(moduleConfig.telemetry.environment_measurement_enabled || moduleConfig.telemetry.environment_screen_enabled)) { // If this module is not enabled, and the user doesn't want the display screen don't waste any OSThread time on it return disable(); } @@ -78,15 +76,15 @@ int32_t EnvironmentTelemetryModule::runOnce() LOG_INFO("Environment Telemetry: Initializing\n"); // it's possible to have this module enabled, only for displaying values on the screen. // therefore, we should only enable the sensor loop if measurement is also enabled - if (bmp280Sensor.hasSensor()) + if (bmp280Sensor.hasSensor()) result = bmp280Sensor.runOnce(); - if (bme280Sensor.hasSensor()) + if (bme280Sensor.hasSensor()) result = bme280Sensor.runOnce(); - if (bme680Sensor.hasSensor()) + if (bme680Sensor.hasSensor()) result = bme680Sensor.runOnce(); - if (mcp9808Sensor.hasSensor()) + if (mcp9808Sensor.hasSensor()) result = mcp9808Sensor.runOnce(); - if (ina260Sensor.hasSensor()) + if (ina260Sensor.hasSensor()) result = ina260Sensor.runOnce(); if (ina219Sensor.hasSensor()) result = ina219Sensor.runOnce(); @@ -105,8 +103,8 @@ int32_t EnvironmentTelemetryModule::runOnce() return result; uint32_t now = millis(); - if ((lastSentToMesh == 0 || - (now - lastSentToMesh) >= getConfiguredOrDefaultMs(moduleConfig.telemetry.environment_update_interval)) && + if ((lastSentToMesh == 0 || + (now - lastSentToMesh) >= getConfiguredOrDefaultMs(moduleConfig.telemetry.environment_update_interval)) && airTime->isTxAllowedAirUtil()) { sendTelemetry(); lastSentToMesh = now; @@ -173,13 +171,15 @@ void EnvironmentTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiSt } display->drawString(x, y += fontHeight(FONT_MEDIUM) - 2, "From: " + String(lastSender) + "(" + String(agoSecs) + "s)"); display->drawString(x, y += fontHeight(FONT_SMALL) - 2, - "Temp/Hum: " + last_temp + " / " + String(lastMeasurement.variant.environment_metrics.relative_humidity, 0) + "%"); + "Temp/Hum: " + last_temp + " / " + + String(lastMeasurement.variant.environment_metrics.relative_humidity, 0) + "%"); if (lastMeasurement.variant.environment_metrics.barometric_pressure != 0) display->drawString(x, y += fontHeight(FONT_SMALL), - "Press: " + String(lastMeasurement.variant.environment_metrics.barometric_pressure, 0) + "hPA"); + "Press: " + String(lastMeasurement.variant.environment_metrics.barometric_pressure, 0) + "hPA"); if (lastMeasurement.variant.environment_metrics.voltage != 0) display->drawString(x, y += fontHeight(FONT_SMALL), - "Volt/Cur: " + String(lastMeasurement.variant.environment_metrics.voltage, 0) + "V / " + String(lastMeasurement.variant.environment_metrics.current, 0) + "mA"); + "Volt/Cur: " + String(lastMeasurement.variant.environment_metrics.voltage, 0) + "V / " + + String(lastMeasurement.variant.environment_metrics.current, 0) + "mA"); } bool EnvironmentTelemetryModule::handleReceivedProtobuf(const MeshPacket &mp, Telemetry *t) @@ -187,14 +187,11 @@ bool EnvironmentTelemetryModule::handleReceivedProtobuf(const MeshPacket &mp, Te if (t->which_variant == Telemetry_environment_metrics_tag) { const char *sender = getSenderShortName(mp); - LOG_INFO("(Received from %s): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, temperature=%f, voltage=%f\n", - sender, - t->variant.environment_metrics.barometric_pressure, - t->variant.environment_metrics.current, - t->variant.environment_metrics.gas_resistance, - t->variant.environment_metrics.relative_humidity, - t->variant.environment_metrics.temperature, - t->variant.environment_metrics.voltage); + LOG_INFO("(Received from %s): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, " + "temperature=%f, voltage=%f\n", + sender, t->variant.environment_metrics.barometric_pressure, t->variant.environment_metrics.current, + t->variant.environment_metrics.gas_resistance, t->variant.environment_metrics.relative_humidity, + t->variant.environment_metrics.temperature, t->variant.environment_metrics.voltage); lastMeasurementPacket = packetPool.allocCopy(mp); } @@ -234,13 +231,11 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) if (ina260Sensor.hasSensor()) ina260Sensor.getMetrics(&m); - LOG_INFO("(Sending): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, temperature=%f, voltage=%f\n", - 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.temperature, - m.variant.environment_metrics.voltage); + LOG_INFO( + "(Sending): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, temperature=%f, voltage=%f\n", + 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.temperature, m.variant.environment_metrics.voltage); sensor_read_error_count = 0; diff --git a/src/modules/Telemetry/EnvironmentTelemetry.h b/src/modules/Telemetry/EnvironmentTelemetry.h index c081ead51..5dce19c57 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.h +++ b/src/modules/Telemetry/EnvironmentTelemetry.h @@ -1,5 +1,5 @@ #pragma once -#include "../mesh/generated/telemetry.pb.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" #include "NodeDB.h" #include "ProtobufModule.h" #include @@ -12,8 +12,8 @@ class EnvironmentTelemetryModule : private concurrency::OSThread, public Protobu : concurrency::OSThread("EnvironmentTelemetryModule"), ProtobufModule("EnvironmentTelemetry", PortNum_TELEMETRY_APP, &Telemetry_msg) { - lastMeasurementPacket = nullptr; - setIntervalFromNow(10 * 1000); + lastMeasurementPacket = nullptr; + setIntervalFromNow(10 * 1000); } virtual bool wantUIFrame() override; #if !HAS_SCREEN diff --git a/src/modules/Telemetry/Sensor/BME280Sensor.cpp b/src/modules/Telemetry/Sensor/BME280Sensor.cpp index 26f48f89d..6c173eaec 100644 --- a/src/modules/Telemetry/Sensor/BME280Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BME280Sensor.cpp @@ -1,35 +1,33 @@ -#include "../mesh/generated/telemetry.pb.h" -#include "configuration.h" -#include "TelemetrySensor.h" #include "BME280Sensor.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "TelemetrySensor.h" +#include "configuration.h" #include #include -BME280Sensor::BME280Sensor() : - TelemetrySensor(TelemetrySensorType_BME280, "BME280") -{ -} +BME280Sensor::BME280Sensor() : TelemetrySensor(TelemetrySensorType_BME280, "BME280") {} -int32_t BME280Sensor::runOnce() { +int32_t BME280Sensor::runOnce() +{ LOG_INFO("Init sensor: %s\n", sensorName); if (!hasSensor()) { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; } - status = bme280.begin(nodeTelemetrySensorsMap[sensorType]); - - bme280.setSampling( Adafruit_BME280::MODE_FORCED, - Adafruit_BME280::SAMPLING_X1, // Temp. oversampling - Adafruit_BME280::SAMPLING_X1, // Pressure oversampling - Adafruit_BME280::SAMPLING_X1, // Humidity oversampling - Adafruit_BME280::FILTER_OFF, - Adafruit_BME280::STANDBY_MS_1000); - + status = bme280.begin(nodeTelemetrySensorsMap[sensorType]); + + bme280.setSampling(Adafruit_BME280::MODE_FORCED, + Adafruit_BME280::SAMPLING_X1, // Temp. oversampling + Adafruit_BME280::SAMPLING_X1, // Pressure oversampling + Adafruit_BME280::SAMPLING_X1, // Humidity oversampling + Adafruit_BME280::FILTER_OFF, Adafruit_BME280::STANDBY_MS_1000); + return initI2CSensor(); } -void BME280Sensor::setup() { } +void BME280Sensor::setup() {} -bool BME280Sensor::getMetrics(Telemetry *measurement) { +bool BME280Sensor::getMetrics(Telemetry *measurement) +{ LOG_DEBUG("BME280Sensor::getMetrics\n"); bme280.takeForcedMeasurement(); measurement->variant.environment_metrics.temperature = bme280.readTemperature(); @@ -37,4 +35,4 @@ bool BME280Sensor::getMetrics(Telemetry *measurement) { measurement->variant.environment_metrics.barometric_pressure = bme280.readPressure() / 100.0F; return true; -} \ No newline at end of file +} \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/BME280Sensor.h b/src/modules/Telemetry/Sensor/BME280Sensor.h index 166796a37..c75b9ef59 100644 --- a/src/modules/Telemetry/Sensor/BME280Sensor.h +++ b/src/modules/Telemetry/Sensor/BME280Sensor.h @@ -1,16 +1,17 @@ -#include "../mesh/generated/telemetry.pb.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include -class BME280Sensor : virtual public TelemetrySensor { -private: +class BME280Sensor : virtual public TelemetrySensor +{ + private: Adafruit_BME280 bme280; -protected: + protected: virtual void setup() override; -public: + public: BME280Sensor(); virtual int32_t runOnce() override; virtual bool getMetrics(Telemetry *measurement) override; -}; \ No newline at end of file +}; \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/BME680Sensor.cpp b/src/modules/Telemetry/Sensor/BME680Sensor.cpp index 44690fbaa..e3266450a 100644 --- a/src/modules/Telemetry/Sensor/BME680Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BME680Sensor.cpp @@ -1,15 +1,13 @@ -#include "../mesh/generated/telemetry.pb.h" -#include "configuration.h" -#include "TelemetrySensor.h" #include "BME680Sensor.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "TelemetrySensor.h" +#include "configuration.h" #include -BME680Sensor::BME680Sensor() : - TelemetrySensor(TelemetrySensorType_BME680, "BME680") -{ -} +BME680Sensor::BME680Sensor() : TelemetrySensor(TelemetrySensorType_BME680, "BME680") {} -int32_t BME680Sensor::runOnce() { +int32_t BME680Sensor::runOnce() +{ LOG_INFO("Init sensor: %s\n", sensorName); if (!hasSensor()) { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; @@ -19,9 +17,10 @@ int32_t BME680Sensor::runOnce() { return initI2CSensor(); } -void BME680Sensor::setup() { } +void BME680Sensor::setup() {} -bool BME680Sensor::getMetrics(Telemetry *measurement) { +bool BME680Sensor::getMetrics(Telemetry *measurement) +{ bme680.performReading(); measurement->variant.environment_metrics.temperature = bme680.temperature; measurement->variant.environment_metrics.relative_humidity = bme680.humidity; @@ -29,4 +28,4 @@ bool BME680Sensor::getMetrics(Telemetry *measurement) { measurement->variant.environment_metrics.gas_resistance = bme680.gas_resistance / 1000.0; return true; -} \ No newline at end of file +} \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/BME680Sensor.h b/src/modules/Telemetry/Sensor/BME680Sensor.h index a3c37203d..e66eba75c 100644 --- a/src/modules/Telemetry/Sensor/BME680Sensor.h +++ b/src/modules/Telemetry/Sensor/BME680Sensor.h @@ -1,16 +1,17 @@ -#include "../mesh/generated/telemetry.pb.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include -class BME680Sensor : virtual public TelemetrySensor { -private: +class BME680Sensor : virtual public TelemetrySensor +{ + private: Adafruit_BME680 bme680; -protected: + protected: virtual void setup() override; - -public: + + public: BME680Sensor(); virtual int32_t runOnce() override; virtual bool getMetrics(Telemetry *measurement) override; -}; \ No newline at end of file +}; \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/BMP280Sensor.cpp b/src/modules/Telemetry/Sensor/BMP280Sensor.cpp index eddc30649..267656c4c 100644 --- a/src/modules/Telemetry/Sensor/BMP280Sensor.cpp +++ b/src/modules/Telemetry/Sensor/BMP280Sensor.cpp @@ -1,38 +1,36 @@ -#include "../mesh/generated/telemetry.pb.h" -#include "configuration.h" -#include "TelemetrySensor.h" #include "BMP280Sensor.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "TelemetrySensor.h" +#include "configuration.h" #include #include -BMP280Sensor::BMP280Sensor() : - TelemetrySensor(TelemetrySensorType_BMP280, "BMP280") -{ -} +BMP280Sensor::BMP280Sensor() : TelemetrySensor(TelemetrySensorType_BMP280, "BMP280") {} -int32_t BMP280Sensor::runOnce() { +int32_t BMP280Sensor::runOnce() +{ LOG_INFO("Init sensor: %s\n", sensorName); if (!hasSensor()) { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; } - status = bmp280.begin(nodeTelemetrySensorsMap[sensorType]); + status = bmp280.begin(nodeTelemetrySensorsMap[sensorType]); - bmp280.setSampling( Adafruit_BMP280::MODE_FORCED, - Adafruit_BMP280::SAMPLING_X1, // Temp. oversampling - Adafruit_BMP280::SAMPLING_X1, // Pressure oversampling - Adafruit_BMP280::FILTER_OFF, - Adafruit_BMP280::STANDBY_MS_1000); + bmp280.setSampling(Adafruit_BMP280::MODE_FORCED, + Adafruit_BMP280::SAMPLING_X1, // Temp. oversampling + Adafruit_BMP280::SAMPLING_X1, // Pressure oversampling + Adafruit_BMP280::FILTER_OFF, Adafruit_BMP280::STANDBY_MS_1000); return initI2CSensor(); } -void BMP280Sensor::setup() { } +void BMP280Sensor::setup() {} -bool BMP280Sensor::getMetrics(Telemetry *measurement) { +bool BMP280Sensor::getMetrics(Telemetry *measurement) +{ LOG_DEBUG("BMP280Sensor::getMetrics\n"); bmp280.takeForcedMeasurement(); measurement->variant.environment_metrics.temperature = bmp280.readTemperature(); measurement->variant.environment_metrics.barometric_pressure = bmp280.readPressure() / 100.0F; return true; -} +} diff --git a/src/modules/Telemetry/Sensor/BMP280Sensor.h b/src/modules/Telemetry/Sensor/BMP280Sensor.h index 3525f3fa3..769f4e4ba 100644 --- a/src/modules/Telemetry/Sensor/BMP280Sensor.h +++ b/src/modules/Telemetry/Sensor/BMP280Sensor.h @@ -1,16 +1,17 @@ -#include "../mesh/generated/telemetry.pb.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include -class BMP280Sensor : virtual public TelemetrySensor { -private: +class BMP280Sensor : virtual public TelemetrySensor +{ + private: Adafruit_BMP280 bmp280; -protected: + protected: virtual void setup() override; -public: + public: BMP280Sensor(); virtual int32_t runOnce() override; virtual bool getMetrics(Telemetry *measurement) override; -}; \ No newline at end of file +}; \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/INA219Sensor.cpp b/src/modules/Telemetry/Sensor/INA219Sensor.cpp index 4a732e73d..69a67ad4b 100644 --- a/src/modules/Telemetry/Sensor/INA219Sensor.cpp +++ b/src/modules/Telemetry/Sensor/INA219Sensor.cpp @@ -1,15 +1,13 @@ -#include "../mesh/generated/telemetry.pb.h" -#include "configuration.h" -#include "TelemetrySensor.h" #include "INA219Sensor.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "TelemetrySensor.h" +#include "configuration.h" #include -INA219Sensor::INA219Sensor() : - TelemetrySensor(TelemetrySensorType_INA219, "INA219") -{ -} +INA219Sensor::INA219Sensor() : TelemetrySensor(TelemetrySensorType_INA219, "INA219") {} -int32_t INA219Sensor::runOnce() { +int32_t INA219Sensor::runOnce() +{ LOG_INFO("Init sensor: %s\n", sensorName); if (!hasSensor()) { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; @@ -19,12 +17,11 @@ int32_t INA219Sensor::runOnce() { return initI2CSensor(); } -void INA219Sensor::setup() -{ -} +void INA219Sensor::setup() {} -bool INA219Sensor::getMetrics(Telemetry *measurement) { +bool INA219Sensor::getMetrics(Telemetry *measurement) +{ measurement->variant.environment_metrics.voltage = ina219.getBusVoltage_V(); measurement->variant.environment_metrics.current = ina219.getCurrent_mA(); return true; -} \ No newline at end of file +} \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/INA219Sensor.h b/src/modules/Telemetry/Sensor/INA219Sensor.h index 7e0a3c17e..7288dac8a 100644 --- a/src/modules/Telemetry/Sensor/INA219Sensor.h +++ b/src/modules/Telemetry/Sensor/INA219Sensor.h @@ -1,17 +1,17 @@ -#include "../mesh/generated/telemetry.pb.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include - -class INA219Sensor : virtual public TelemetrySensor { -private: +class INA219Sensor : virtual public TelemetrySensor +{ + private: Adafruit_INA219 ina219; -protected: + protected: virtual void setup() override; - -public: + + public: INA219Sensor(); virtual int32_t runOnce() override; virtual bool getMetrics(Telemetry *measurement) override; -}; \ No newline at end of file +}; \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/INA260Sensor.cpp b/src/modules/Telemetry/Sensor/INA260Sensor.cpp index 5b3064e7d..d69d25a75 100644 --- a/src/modules/Telemetry/Sensor/INA260Sensor.cpp +++ b/src/modules/Telemetry/Sensor/INA260Sensor.cpp @@ -1,15 +1,13 @@ -#include "../mesh/generated/telemetry.pb.h" -#include "configuration.h" -#include "TelemetrySensor.h" #include "INA260Sensor.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "TelemetrySensor.h" +#include "configuration.h" #include -INA260Sensor::INA260Sensor() : - TelemetrySensor(TelemetrySensorType_INA260, "INA260") -{ -} +INA260Sensor::INA260Sensor() : TelemetrySensor(TelemetrySensorType_INA260, "INA260") {} -int32_t INA260Sensor::runOnce() { +int32_t INA260Sensor::runOnce() +{ LOG_INFO("Init sensor: %s\n", sensorName); if (!hasSensor()) { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; @@ -18,13 +16,12 @@ int32_t INA260Sensor::runOnce() { return initI2CSensor(); } -void INA260Sensor::setup() -{ -} +void INA260Sensor::setup() {} -bool INA260Sensor::getMetrics(Telemetry *measurement) { +bool INA260Sensor::getMetrics(Telemetry *measurement) +{ // mV conversion to V measurement->variant.environment_metrics.voltage = ina260.readBusVoltage() / 1000; measurement->variant.environment_metrics.current = ina260.readCurrent(); return true; -} \ No newline at end of file +} \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/INA260Sensor.h b/src/modules/Telemetry/Sensor/INA260Sensor.h index 789b66c2d..de1fe0ad7 100644 --- a/src/modules/Telemetry/Sensor/INA260Sensor.h +++ b/src/modules/Telemetry/Sensor/INA260Sensor.h @@ -1,17 +1,17 @@ -#include "../mesh/generated/telemetry.pb.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include - -class INA260Sensor : virtual public TelemetrySensor { -private: +class INA260Sensor : virtual public TelemetrySensor +{ + private: Adafruit_INA260 ina260 = Adafruit_INA260(); -protected: + protected: virtual void setup() override; - -public: + + public: INA260Sensor(); virtual int32_t runOnce() override; virtual bool getMetrics(Telemetry *measurement) override; -}; \ No newline at end of file +}; \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/LPS22HBSensor.cpp b/src/modules/Telemetry/Sensor/LPS22HBSensor.cpp index 1f75a9aa1..ac77bdb40 100644 --- a/src/modules/Telemetry/Sensor/LPS22HBSensor.cpp +++ b/src/modules/Telemetry/Sensor/LPS22HBSensor.cpp @@ -1,16 +1,14 @@ -#include "../mesh/generated/telemetry.pb.h" -#include "configuration.h" -#include "TelemetrySensor.h" #include "LPS22HBSensor.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "TelemetrySensor.h" +#include "configuration.h" #include #include -LPS22HBSensor::LPS22HBSensor() : - TelemetrySensor(TelemetrySensorType_LPS22, "LPS22HB") -{ -} +LPS22HBSensor::LPS22HBSensor() : TelemetrySensor(TelemetrySensorType_LPS22, "LPS22HB") {} -int32_t LPS22HBSensor::runOnce() { +int32_t LPS22HBSensor::runOnce() +{ LOG_INFO("Init sensor: %s\n", sensorName); if (!hasSensor()) { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; @@ -19,12 +17,13 @@ int32_t LPS22HBSensor::runOnce() { return initI2CSensor(); } -void LPS22HBSensor::setup() +void LPS22HBSensor::setup() { lps22hb.setDataRate(LPS22_RATE_10_HZ); } -bool LPS22HBSensor::getMetrics(Telemetry *measurement) { +bool LPS22HBSensor::getMetrics(Telemetry *measurement) +{ sensors_event_t temp; sensors_event_t pressure; lps22hb.getEvent(&pressure, &temp); @@ -33,4 +32,4 @@ bool LPS22HBSensor::getMetrics(Telemetry *measurement) { measurement->variant.environment_metrics.barometric_pressure = pressure.pressure; return true; -} \ No newline at end of file +} \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/LPS22HBSensor.h b/src/modules/Telemetry/Sensor/LPS22HBSensor.h index 1ded032fb..7472950b8 100644 --- a/src/modules/Telemetry/Sensor/LPS22HBSensor.h +++ b/src/modules/Telemetry/Sensor/LPS22HBSensor.h @@ -1,17 +1,18 @@ -#include "../mesh/generated/telemetry.pb.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include #include -class LPS22HBSensor : virtual public TelemetrySensor { -private: +class LPS22HBSensor : virtual public TelemetrySensor +{ + private: Adafruit_LPS22 lps22hb; -protected: + protected: virtual void setup() override; - -public: + + public: LPS22HBSensor(); virtual int32_t runOnce() override; virtual bool getMetrics(Telemetry *measurement) override; -}; \ No newline at end of file +}; \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/MCP9808Sensor.cpp b/src/modules/Telemetry/Sensor/MCP9808Sensor.cpp index 4dd3be635..7bac18d9a 100644 --- a/src/modules/Telemetry/Sensor/MCP9808Sensor.cpp +++ b/src/modules/Telemetry/Sensor/MCP9808Sensor.cpp @@ -1,15 +1,13 @@ -#include "../mesh/generated/telemetry.pb.h" -#include "configuration.h" -#include "TelemetrySensor.h" #include "MCP9808Sensor.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "TelemetrySensor.h" +#include "configuration.h" #include -MCP9808Sensor::MCP9808Sensor() : - TelemetrySensor(TelemetrySensorType_MCP9808, "MCP9808") -{ -} +MCP9808Sensor::MCP9808Sensor() : TelemetrySensor(TelemetrySensorType_MCP9808, "MCP9808") {} -int32_t MCP9808Sensor::runOnce() { +int32_t MCP9808Sensor::runOnce() +{ LOG_INFO("Init sensor: %s\n", sensorName); if (!hasSensor()) { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; @@ -18,12 +16,14 @@ int32_t MCP9808Sensor::runOnce() { return initI2CSensor(); } -void MCP9808Sensor::setup() { +void MCP9808Sensor::setup() +{ mcp9808.setResolution(2); } -bool MCP9808Sensor::getMetrics(Telemetry *measurement) { +bool MCP9808Sensor::getMetrics(Telemetry *measurement) +{ LOG_DEBUG("MCP9808Sensor::getMetrics\n"); measurement->variant.environment_metrics.temperature = mcp9808.readTempC(); return true; -} \ No newline at end of file +} \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/MCP9808Sensor.h b/src/modules/Telemetry/Sensor/MCP9808Sensor.h index 81f50b886..150b76237 100644 --- a/src/modules/Telemetry/Sensor/MCP9808Sensor.h +++ b/src/modules/Telemetry/Sensor/MCP9808Sensor.h @@ -1,16 +1,17 @@ -#include "../mesh/generated/telemetry.pb.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include -class MCP9808Sensor : virtual public TelemetrySensor { -private: +class MCP9808Sensor : virtual public TelemetrySensor +{ + private: Adafruit_MCP9808 mcp9808; -protected: + protected: virtual void setup() override; - -public: + + public: MCP9808Sensor(); virtual int32_t runOnce() override; virtual bool getMetrics(Telemetry *measurement) override; -}; \ No newline at end of file +}; \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/SHT31Sensor.cpp b/src/modules/Telemetry/Sensor/SHT31Sensor.cpp index 528d5a030..940a94d46 100644 --- a/src/modules/Telemetry/Sensor/SHT31Sensor.cpp +++ b/src/modules/Telemetry/Sensor/SHT31Sensor.cpp @@ -1,31 +1,30 @@ -#include "../mesh/generated/telemetry.pb.h" -#include "configuration.h" -#include "TelemetrySensor.h" #include "SHT31Sensor.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "TelemetrySensor.h" +#include "configuration.h" #include -SHT31Sensor::SHT31Sensor() : - TelemetrySensor(TelemetrySensorType_SHT31, "SHT31") -{ -} +SHT31Sensor::SHT31Sensor() : TelemetrySensor(TelemetrySensorType_SHT31, "SHT31") {} -int32_t SHT31Sensor::runOnce() { +int32_t SHT31Sensor::runOnce() +{ LOG_INFO("Init sensor: %s\n", sensorName); if (!hasSensor()) { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; } - status = sht31.begin(); + status = sht31.begin(); return initI2CSensor(); } -void SHT31Sensor::setup() +void SHT31Sensor::setup() { // Set up oversampling and filter initialization } -bool SHT31Sensor::getMetrics(Telemetry *measurement) { +bool SHT31Sensor::getMetrics(Telemetry *measurement) +{ measurement->variant.environment_metrics.temperature = sht31.readTemperature(); measurement->variant.environment_metrics.relative_humidity = sht31.readHumidity(); return true; -} +} diff --git a/src/modules/Telemetry/Sensor/SHT31Sensor.h b/src/modules/Telemetry/Sensor/SHT31Sensor.h index 5f236e21e..ca574a5cd 100644 --- a/src/modules/Telemetry/Sensor/SHT31Sensor.h +++ b/src/modules/Telemetry/Sensor/SHT31Sensor.h @@ -1,16 +1,17 @@ -#include "../mesh/generated/telemetry.pb.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include -class SHT31Sensor : virtual public TelemetrySensor { -private: +class SHT31Sensor : virtual public TelemetrySensor +{ + private: Adafruit_SHT31 sht31 = Adafruit_SHT31(); -protected: + protected: virtual void setup() override; - -public: + + public: SHT31Sensor(); virtual int32_t runOnce() override; virtual bool getMetrics(Telemetry *measurement) override; -}; +}; diff --git a/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp b/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp index 3a20d37a1..1ed16cc11 100644 --- a/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp +++ b/src/modules/Telemetry/Sensor/SHTC3Sensor.cpp @@ -1,29 +1,28 @@ -#include "../mesh/generated/telemetry.pb.h" -#include "configuration.h" -#include "TelemetrySensor.h" #include "SHTC3Sensor.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "TelemetrySensor.h" +#include "configuration.h" #include -SHTC3Sensor::SHTC3Sensor() : - TelemetrySensor(TelemetrySensorType_SHTC3, "SHTC3") -{ -} +SHTC3Sensor::SHTC3Sensor() : TelemetrySensor(TelemetrySensorType_SHTC3, "SHTC3") {} -int32_t SHTC3Sensor::runOnce() { +int32_t SHTC3Sensor::runOnce() +{ LOG_INFO("Init sensor: %s\n", sensorName); if (!hasSensor()) { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; } - status = shtc3.begin(); + status = shtc3.begin(); return initI2CSensor(); } -void SHTC3Sensor::setup() +void SHTC3Sensor::setup() { // Set up oversampling and filter initialization } -bool SHTC3Sensor::getMetrics(Telemetry *measurement) { +bool SHTC3Sensor::getMetrics(Telemetry *measurement) +{ sensors_event_t humidity, temp; shtc3.getEvent(&humidity, &temp); @@ -31,4 +30,4 @@ bool SHTC3Sensor::getMetrics(Telemetry *measurement) { measurement->variant.environment_metrics.relative_humidity = humidity.relative_humidity; return true; -} \ No newline at end of file +} \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/SHTC3Sensor.h b/src/modules/Telemetry/Sensor/SHTC3Sensor.h index 28a1648bb..f391580a6 100644 --- a/src/modules/Telemetry/Sensor/SHTC3Sensor.h +++ b/src/modules/Telemetry/Sensor/SHTC3Sensor.h @@ -1,16 +1,17 @@ -#include "../mesh/generated/telemetry.pb.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include -class SHTC3Sensor : virtual public TelemetrySensor { -private: +class SHTC3Sensor : virtual public TelemetrySensor +{ + private: Adafruit_SHTC3 shtc3 = Adafruit_SHTC3(); -protected: + protected: virtual void setup() override; - -public: + + public: SHTC3Sensor(); virtual int32_t runOnce() override; virtual bool getMetrics(Telemetry *measurement) override; -}; \ No newline at end of file +}; \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/TelemetrySensor.cpp b/src/modules/Telemetry/Sensor/TelemetrySensor.cpp index e811d7182..cd8fe2566 100644 --- a/src/modules/Telemetry/Sensor/TelemetrySensor.cpp +++ b/src/modules/Telemetry/Sensor/TelemetrySensor.cpp @@ -1,4 +1,4 @@ #include "TelemetrySensor.h" -#include "../mesh/generated/telemetry.pb.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" #include "NodeDB.h" #include "main.h" diff --git a/src/modules/Telemetry/Sensor/TelemetrySensor.h b/src/modules/Telemetry/Sensor/TelemetrySensor.h index 87f2d68ba..79dfbf312 100644 --- a/src/modules/Telemetry/Sensor/TelemetrySensor.h +++ b/src/modules/Telemetry/Sensor/TelemetrySensor.h @@ -1,5 +1,5 @@ #pragma once -#include "../mesh/generated/telemetry.pb.h" +#include "../mesh/generated/meshtastic/telemetry.pb.h" #include "NodeDB.h" #include "main.h" @@ -19,7 +19,8 @@ class TelemetrySensor TelemetrySensorType sensorType; unsigned status; - int32_t initI2CSensor() { + int32_t initI2CSensor() + { if (!status) { LOG_WARN("Could not connect to detected %s sensor.\n Removing from nodeTelemetrySensorsMap.\n", sensorName); nodeTelemetrySensorsMap[sensorType] = 0; @@ -32,9 +33,7 @@ class TelemetrySensor virtual void setup(); public: - bool hasSensor() { - return sensorType < sizeof(nodeTelemetrySensorsMap) && nodeTelemetrySensorsMap[sensorType] > 0; - } + bool hasSensor() { return sensorType < sizeof(nodeTelemetrySensorsMap) && nodeTelemetrySensorsMap[sensorType] > 0; } virtual int32_t runOnce() = 0; virtual bool getMetrics(Telemetry *measurement) = 0; diff --git a/src/modules/esp32/StoreForwardModule.cpp b/src/modules/esp32/StoreForwardModule.cpp index ba0e7d6ee..36d023162 100644 --- a/src/modules/esp32/StoreForwardModule.cpp +++ b/src/modules/esp32/StoreForwardModule.cpp @@ -6,7 +6,7 @@ #include "airtime.h" #include "configuration.h" #include "mesh-pb-constants.h" -#include "mesh/generated/storeforward.pb.h" +#include "mesh/generated/meshtastic/storeforward.pb.h" #include "modules/ModuleDev.h" #include #include @@ -63,7 +63,8 @@ void StoreForwardModule::populatePSRAM() https://learn.upesy.com/en/programmation/psram.html#psram-tab */ - LOG_DEBUG("*** Before PSRAM initilization: heap %d/%d PSRAM %d/%d\n", ESP.getFreeHeap(), ESP.getHeapSize(), ESP.getFreePsram(), ESP.getPsramSize()); + LOG_DEBUG("*** Before PSRAM initilization: heap %d/%d PSRAM %d/%d\n", ESP.getFreeHeap(), ESP.getHeapSize(), + ESP.getFreePsram(), ESP.getPsramSize()); this->packetHistoryTXQueue = static_cast(ps_calloc(this->historyReturnMax, sizeof(PacketHistoryStruct))); @@ -76,7 +77,8 @@ void StoreForwardModule::populatePSRAM() this->packetHistory = static_cast(ps_calloc(numberOfPackets, sizeof(PacketHistoryStruct))); - LOG_DEBUG("*** After PSRAM initilization: heap %d/%d PSRAM %d/%d\n", ESP.getFreeHeap(), ESP.getHeapSize(), ESP.getFreePsram(), ESP.getPsramSize()); + LOG_DEBUG("*** After PSRAM initilization: heap %d/%d PSRAM %d/%d\n", ESP.getFreeHeap(), ESP.getHeapSize(), ESP.getFreePsram(), + ESP.getPsramSize()); LOG_DEBUG("*** numberOfPackets for packetHistory - %u\n", numberOfPackets); } @@ -296,123 +298,125 @@ bool StoreForwardModule::handleReceivedProtobuf(const MeshPacket &mp, StoreAndFo requests++; switch (p->rr) { - case StoreAndForward_RequestResponse_CLIENT_ERROR: - case StoreAndForward_RequestResponse_CLIENT_ABORT: - if(is_server) { - // stop sending stuff, the client wants to abort or has another error - if ((this->busy) && (this->busyTo == getFrom(&mp))) { - LOG_ERROR("*** Client in ERROR or ABORT requested\n"); - this->packetHistoryTXQueue_index = 0; - this->busy = false; - } + case StoreAndForward_RequestResponse_CLIENT_ERROR: + case StoreAndForward_RequestResponse_CLIENT_ABORT: + if (is_server) { + // stop sending stuff, the client wants to abort or has another error + if ((this->busy) && (this->busyTo == getFrom(&mp))) { + LOG_ERROR("*** Client in ERROR or ABORT requested\n"); + this->packetHistoryTXQueue_index = 0; + this->busy = false; } - break; + } + break; - case StoreAndForward_RequestResponse_CLIENT_HISTORY: - if(is_server) { - requests_history++; - LOG_INFO("*** Client Request to send HISTORY\n"); - // Send the last 60 minutes of messages. - if (this->busy) { - storeForwardModule->sendMessage(getFrom(&mp), StoreAndForward_RequestResponse_ROUTER_BUSY); - LOG_INFO("*** S&F - Busy. Try again shortly.\n"); + case StoreAndForward_RequestResponse_CLIENT_HISTORY: + if (is_server) { + requests_history++; + LOG_INFO("*** Client Request to send HISTORY\n"); + // Send the last 60 minutes of messages. + if (this->busy) { + storeForwardModule->sendMessage(getFrom(&mp), StoreAndForward_RequestResponse_ROUTER_BUSY); + LOG_INFO("*** S&F - Busy. Try again shortly.\n"); + } else { + if ((p->which_variant == StoreAndForward_history_tag) && (p->variant.history.window > 0)) { + storeForwardModule->historySend(p->variant.history.window * 60000, getFrom(&mp)); // window is in minutes } else { - if ((p->which_variant == StoreAndForward_history_tag) && (p->variant.history.window > 0)){ - storeForwardModule->historySend(p->variant.history.window * 60000, getFrom(&mp)); // window is in minutes - } else { - storeForwardModule->historySend(historyReturnWindow * 60000, getFrom(&mp)); // defaults to 4 hours - } + storeForwardModule->historySend(historyReturnWindow * 60000, getFrom(&mp)); // defaults to 4 hours } } - break; + } + break; - case StoreAndForward_RequestResponse_CLIENT_PING: - if(is_server) { - LOG_INFO("*** StoreAndForward_RequestResponse_CLIENT_PING\n"); - // respond with a ROUTER PONG - storeForwardModule->sendMessage(getFrom(&mp), StoreAndForward_RequestResponse_ROUTER_PONG); + case StoreAndForward_RequestResponse_CLIENT_PING: + if (is_server) { + LOG_INFO("*** StoreAndForward_RequestResponse_CLIENT_PING\n"); + // respond with a ROUTER PONG + storeForwardModule->sendMessage(getFrom(&mp), StoreAndForward_RequestResponse_ROUTER_PONG); + } + break; + + case StoreAndForward_RequestResponse_CLIENT_PONG: + if (is_server) { + LOG_INFO("*** StoreAndForward_RequestResponse_CLIENT_PONG\n"); + // The Client is alive, update NodeDB + nodeDB.updateFrom(mp); + } + break; + + case StoreAndForward_RequestResponse_CLIENT_STATS: + if (is_server) { + LOG_INFO("*** Client Request to send STATS\n"); + if (this->busy) { + storeForwardModule->sendMessage(getFrom(&mp), StoreAndForward_RequestResponse_ROUTER_BUSY); + LOG_INFO("*** S&F - Busy. Try again shortly.\n"); + } else { + storeForwardModule->statsSend(getFrom(&mp)); } - break; + } + break; - case StoreAndForward_RequestResponse_CLIENT_PONG: - if(is_server) { - LOG_INFO("*** StoreAndForward_RequestResponse_CLIENT_PONG\n"); - // The Client is alive, update NodeDB - nodeDB.updateFrom(mp); + case StoreAndForward_RequestResponse_ROUTER_ERROR: + case StoreAndForward_RequestResponse_ROUTER_BUSY: + if (is_client) { + LOG_DEBUG("*** StoreAndForward_RequestResponse_ROUTER_BUSY\n"); + // retry in messages_saved * packetTimeMax ms + retry_delay = + millis() + packetHistoryCurrent * packetTimeMax * (StoreAndForward_RequestResponse_ROUTER_ERROR ? 2 : 1); + } + break; + + case StoreAndForward_RequestResponse_ROUTER_PONG: + // A router responded, this is equal to receiving a heartbeat + case StoreAndForward_RequestResponse_ROUTER_HEARTBEAT: + if (is_client) { + // register heartbeat and interval + if (p->which_variant == StoreAndForward_heartbeat_tag) { + heartbeatInterval = p->variant.heartbeat.period; } - break; + lastHeartbeat = millis(); + LOG_INFO("*** StoreAndForward Heartbeat received\n"); + } + break; - case StoreAndForward_RequestResponse_CLIENT_STATS: - if(is_server) { - LOG_INFO("*** Client Request to send STATS\n"); - if (this->busy) { - storeForwardModule->sendMessage(getFrom(&mp), StoreAndForward_RequestResponse_ROUTER_BUSY); - LOG_INFO("*** S&F - Busy. Try again shortly.\n"); - } else { - storeForwardModule->statsSend(getFrom(&mp)); - } + case StoreAndForward_RequestResponse_ROUTER_PING: + if (is_client) { + LOG_DEBUG("*** StoreAndForward_RequestResponse_ROUTER_PING\n"); + // respond with a CLIENT PONG + storeForwardModule->sendMessage(getFrom(&mp), StoreAndForward_RequestResponse_CLIENT_PONG); + } + break; + + case StoreAndForward_RequestResponse_ROUTER_STATS: + if (is_client) { + LOG_DEBUG("*** Router Response STATS\n"); + // These fields only have informational purpose on a client. Fill them to consume later. + if (p->which_variant == StoreAndForward_stats_tag) { + this->packetHistoryMax = p->variant.stats.messages_total; + this->packetHistoryCurrent = p->variant.stats.messages_saved; + this->records = p->variant.stats.messages_max; + this->requests = p->variant.stats.requests; + this->requests_history = p->variant.stats.requests_history; + this->heartbeat = p->variant.stats.heartbeat; + this->historyReturnMax = p->variant.stats.return_max; + this->historyReturnWindow = p->variant.stats.return_window; } - break; + } + break; - case StoreAndForward_RequestResponse_ROUTER_ERROR: - case StoreAndForward_RequestResponse_ROUTER_BUSY: - if(is_client) { - LOG_DEBUG("*** StoreAndForward_RequestResponse_ROUTER_BUSY\n"); - // retry in messages_saved * packetTimeMax ms - retry_delay = millis() + packetHistoryCurrent * packetTimeMax * (StoreAndForward_RequestResponse_ROUTER_ERROR ? 2 : 1); + case StoreAndForward_RequestResponse_ROUTER_HISTORY: + if (is_client) { + // These fields only have informational purpose on a client. Fill them to consume later. + if (p->which_variant == StoreAndForward_history_tag) { + this->historyReturnWindow = p->variant.history.window / 60000; + LOG_INFO("*** Router Response HISTORY - Sending %d messages from last %d minutes\n", + p->variant.history.history_messages, this->historyReturnWindow); } - break; + } + break; - case StoreAndForward_RequestResponse_ROUTER_PONG: - // A router responded, this is equal to receiving a heartbeat - case StoreAndForward_RequestResponse_ROUTER_HEARTBEAT: - if(is_client) { - // register heartbeat and interval - if (p->which_variant == StoreAndForward_heartbeat_tag) { - heartbeatInterval = p->variant.heartbeat.period; - } - lastHeartbeat = millis(); - LOG_INFO("*** StoreAndForward Heartbeat received\n"); - } - break; - - case StoreAndForward_RequestResponse_ROUTER_PING: - if(is_client) { - LOG_DEBUG("*** StoreAndForward_RequestResponse_ROUTER_PING\n"); - // respond with a CLIENT PONG - storeForwardModule->sendMessage(getFrom(&mp), StoreAndForward_RequestResponse_CLIENT_PONG); - } - break; - - case StoreAndForward_RequestResponse_ROUTER_STATS: - if(is_client) { - LOG_DEBUG("*** Router Response STATS\n"); - // These fields only have informational purpose on a client. Fill them to consume later. - if (p->which_variant == StoreAndForward_stats_tag) { - this->packetHistoryMax = p->variant.stats.messages_total; - this->packetHistoryCurrent = p->variant.stats.messages_saved; - this->records = p->variant.stats.messages_max; - this->requests = p->variant.stats.requests; - this->requests_history = p->variant.stats.requests_history; - this->heartbeat = p->variant.stats.heartbeat; - this->historyReturnMax = p->variant.stats.return_max; - this->historyReturnWindow = p->variant.stats.return_window; - } - } - break; - - case StoreAndForward_RequestResponse_ROUTER_HISTORY: - if(is_client) { - // These fields only have informational purpose on a client. Fill them to consume later. - if (p->which_variant == StoreAndForward_history_tag) { - this->historyReturnWindow = p->variant.history.window / 60000; - LOG_INFO("*** Router Response HISTORY - Sending %d messages from last %d minutes\n", p->variant.history.history_messages, this->historyReturnWindow); - } - } - break; - - default: - assert(0); // unexpected state + default: + assert(0); // unexpected state } return true; // There's no need for others to look at this message. } @@ -437,7 +441,8 @@ StoreForwardModule::StoreForwardModule() if (moduleConfig.store_forward.enabled) { // Router - if ((config.device.role == Config_DeviceConfig_Role_ROUTER) || (config.device.role == Config_DeviceConfig_Role_ROUTER_CLIENT)) { + if ((config.device.role == Config_DeviceConfig_Role_ROUTER) || + (config.device.role == Config_DeviceConfig_Role_ROUTER_CLIENT)) { LOG_INFO("*** Initializing Store & Forward Module in Router mode\n"); if (ESP.getPsramSize() > 0) { if (ESP.getFreePsram() >= 1024 * 1024) { @@ -474,7 +479,8 @@ StoreForwardModule::StoreForwardModule() // Client } - if ((config.device.role == Config_DeviceConfig_Role_CLIENT) || (config.device.role == Config_DeviceConfig_Role_ROUTER_CLIENT)) { + if ((config.device.role == Config_DeviceConfig_Role_CLIENT) || + (config.device.role == Config_DeviceConfig_Role_ROUTER_CLIENT)) { is_client = true; LOG_INFO("*** Initializing Store & Forward Module in Client mode\n"); } diff --git a/src/modules/esp32/StoreForwardModule.h b/src/modules/esp32/StoreForwardModule.h index c9cb72a5b..b1c4084f3 100644 --- a/src/modules/esp32/StoreForwardModule.h +++ b/src/modules/esp32/StoreForwardModule.h @@ -2,7 +2,7 @@ #include "ProtobufModule.h" #include "concurrency/OSThread.h" -#include "mesh/generated/storeforward.pb.h" +#include "mesh/generated/meshtastic/storeforward.pb.h" #include "configuration.h" #include @@ -66,12 +66,12 @@ class StoreForwardModule : private concurrency::OSThread, public ProtobufModule< */ virtual bool wantPacket(const MeshPacket *p) override { - switch(p->decoded.portnum) { - case PortNum_TEXT_MESSAGE_APP: - case PortNum_STORE_FORWARD_APP: - return true; - default: - return false; + switch (p->decoded.portnum) { + case PortNum_TEXT_MESSAGE_APP: + case PortNum_STORE_FORWARD_APP: + return true; + default: + return false; } } @@ -79,10 +79,10 @@ class StoreForwardModule : private concurrency::OSThread, public ProtobufModule< void populatePSRAM(); // S&F Defaults - uint32_t historyReturnMax = 250; // 250 records + uint32_t historyReturnMax = 250; // 250 records uint32_t historyReturnWindow = 240; // 4 hours - uint32_t records = 0; // Calculated - bool heartbeat = false; // No heartbeat. + uint32_t records = 0; // Calculated + bool heartbeat = false; // No heartbeat. // stats uint32_t requests = 0; @@ -100,7 +100,6 @@ class StoreForwardModule : private concurrency::OSThread, public ProtobufModule< */ virtual ProcessMessage handleReceived(const MeshPacket &mp) override; virtual bool handleReceivedProtobuf(const MeshPacket &mp, StoreAndForward *p); - }; extern StoreForwardModule *storeForwardModule; diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 34b75e5bb..a6073af3b 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -5,15 +5,15 @@ #include "main.h" #include "mesh/Channels.h" #include "mesh/Router.h" -#include "mesh/generated/mqtt.pb.h" -#include "mesh/generated/telemetry.pb.h" +#include "mesh/generated/meshtastic/mqtt.pb.h" +#include "mesh/generated/meshtastic/telemetry.pb.h" #include "mesh/http/WiFiAPClient.h" #include "sleep.h" #if HAS_WIFI #include #endif -#include #include "mqtt/JSON.h" +#include MQTT *mqtt; @@ -55,11 +55,15 @@ void MQTT::onPublish(char *topic, byte *payload, unsigned int length) } LOG_DEBUG("Looking for Channel name: %s\n", ptr); Channel sendChannel = channels.getByName(ptr); - LOG_DEBUG("Found Channel name: %s (Index %d)\n", channels.getGlobalId(sendChannel.settings.channel_num), sendChannel.settings.channel_num); + LOG_DEBUG("Found Channel name: %s (Index %d)\n", channels.getGlobalId(sendChannel.settings.channel_num), + sendChannel.settings.channel_num); - if ((json.find("sender") != json.end()) && (json.find("payload") != json.end()) && (json.find("type") != json.end()) && json["type"]->IsString() && (json["type"]->AsString().compare("sendtext") == 0)) { + if ((json.find("sender") != json.end()) && (json.find("payload") != json.end()) && + (json.find("type") != json.end()) && json["type"]->IsString() && + (json["type"]->AsString().compare("sendtext") == 0)) { // this is a valid envelope - if (json["payload"]->IsString() && json["type"]->IsString() && (json["sender"]->AsString().compare(owner.id) != 0)) { + if (json["payload"]->IsString() && json["type"]->IsString() && + (json["sender"]->AsString().compare(owner.id) != 0)) { std::string jsonPayloadStr = json["payload"]->AsString(); LOG_INFO("JSON payload %s, length %u\n", jsonPayloadStr.c_str(), jsonPayloadStr.length()); @@ -77,16 +81,20 @@ void MQTT::onPublish(char *topic, byte *payload, unsigned int length) LOG_WARN("Received MQTT json payload too long, dropping\n"); } } else { - LOG_WARN("Received MQTT json payload on channel %s, but downlink is disabled, dropping\n", sendChannel.settings.name); + LOG_WARN("Received MQTT json payload on channel %s, but downlink is disabled, dropping\n", + sendChannel.settings.name); } } else { LOG_DEBUG("JSON Ignoring downlink message we originally sent.\n"); } - } else if ((json.find("sender") != json.end()) && (json.find("payload") != json.end()) && (json.find("type") != json.end()) && json["type"]->IsString() && (json["type"]->AsString().compare("sendposition") == 0)) { - //invent the "sendposition" type for a valid envelope - if (json["payload"]->IsObject() && json["type"]->IsString() && (json["sender"]->AsString().compare(owner.id) != 0)) { + } else if ((json.find("sender") != json.end()) && (json.find("payload") != json.end()) && + (json.find("type") != json.end()) && json["type"]->IsString() && + (json["type"]->AsString().compare("sendposition") == 0)) { + // invent the "sendposition" type for a valid envelope + if (json["payload"]->IsObject() && json["type"]->IsString() && + (json["sender"]->AsString().compare(owner.id) != 0)) { JSONObject posit; - posit = json["payload"]->AsObject(); //get nested JSON Position + posit = json["payload"]->AsObject(); // get nested JSON Position Position pos = Position_init_default; pos.latitude_i = posit["latitude_i"]->AsNumber(); pos.longitude_i = posit["longitude_i"]->AsNumber(); @@ -98,15 +106,17 @@ void MQTT::onPublish(char *topic, byte *payload, unsigned int length) p->decoded.portnum = PortNum_POSITION_APP; p->channel = sendChannel.settings.channel_num; if (sendChannel.settings.downlink_enabled) { - p->decoded.payload.size = pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes), &Position_msg, &pos); //make the Data protobuf from position + p->decoded.payload.size = pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes), + &Position_msg, &pos); // make the Data protobuf from position service.sendToMesh(p, RX_SRC_LOCAL); } else { - LOG_WARN("Received MQTT json payload on channel %s, but downlink is disabled, dropping\n", sendChannel.settings.name); + LOG_WARN("Received MQTT json payload on channel %s, but downlink is disabled, dropping\n", + sendChannel.settings.name); } } else { LOG_DEBUG("JSON Ignoring downlink message we originally sent.\n"); } - } else{ + } else { LOG_ERROR("JSON Received payload on MQTT but not a valid envelope\n"); } } else { @@ -118,7 +128,7 @@ void MQTT::onPublish(char *topic, byte *payload, unsigned int length) if (!pb_decode_from_bytes(payload, length, &ServiceEnvelope_msg, &e)) { LOG_ERROR("Invalid MQTT service envelope, topic %s, len %u!\n", topic, length); return; - }else { + } else { if (strcmp(e.gateway_id, owner.id) == 0) LOG_INFO("Ignoring downlink message we originally sent.\n"); else { @@ -148,7 +158,7 @@ void mqttInit() MQTT::MQTT() : concurrency::OSThread("mqtt"), pubSub(mqttClient), mqttQueue(MAX_MQTT_QUEUE) { - if(moduleConfig.mqtt.enabled) { + if (moduleConfig.mqtt.enabled) { assert(!mqtt); mqtt = this; @@ -170,7 +180,7 @@ void MQTT::reconnect() { if (wantsLink()) { // Defaults - int serverPort = 1883; + int serverPort = 1883; const char *serverAddr = default_mqtt_address; const char *mqttUsername = default_mqtt_username; const char *mqttPassword = default_mqtt_password; @@ -192,7 +202,8 @@ void MQTT::reconnect() pubSub.setServer(serverAddr, serverPort); pubSub.setBufferSize(512); - LOG_INFO("Connecting to MQTT server %s, port: %d, username: %s, password: %s\n", serverAddr, serverPort, mqttUsername, mqttPassword); + LOG_INFO("Connecting to MQTT server %s, port: %d, username: %s, password: %s\n", serverAddr, serverPort, mqttUsername, + mqttPassword); auto myStatus = (statusTopic + owner.id); bool connected = pubSub.connect(owner.id, mqttUsername, mqttPassword, myStatus.c_str(), 1, true, "offline"); if (connected) { @@ -208,7 +219,7 @@ void MQTT::reconnect() sendSubscriptions(); } else { #if HAS_WIFI && !defined(ARCH_PORTDUINO) - LOG_ERROR("Failed to contact MQTT server (%d/5)...\n",reconnectCount + 1); + LOG_ERROR("Failed to contact MQTT server (%d/5)...\n", reconnectCount + 1); if (reconnectCount >= 4) { needReconnect = true; wifiReconnect->setIntervalFromNow(0); @@ -216,7 +227,7 @@ void MQTT::reconnect() } else { reconnectCount++; } - + #endif } } @@ -267,7 +278,7 @@ bool MQTT::wantsLink() const int32_t MQTT::runOnce() { - if(!moduleConfig.mqtt.enabled) { + if (!moduleConfig.mqtt.enabled) { return disable(); } bool wantConnection = wantsLink(); @@ -277,7 +288,8 @@ int32_t MQTT::runOnce() if (wantConnection) { reconnect(); - // If we succeeded, empty the queue one by one and start reading rapidly, else try again in 30 seconds (TCP connections are EXPENSIVE so try rarely) + // If we succeeded, empty the queue one by one and start reading rapidly, else try again in 30 seconds (TCP + // connections are EXPENSIVE so try rarely) if (pubSub.connected()) { if (!mqttQueue.isEmpty()) { // FIXME - this size calculation is super sloppy, but it will go away once we dynamically alloc meshpackets @@ -295,7 +307,8 @@ int32_t MQTT::runOnce() auto jsonString = this->downstreamPacketToJson(env->packet); if (jsonString.length() != 0) { String topicJson = jsonTopic + env->channel_id + "/" + owner.id; - LOG_INFO("JSON publish message to %s, %u bytes: %s\n", topicJson.c_str(), jsonString.length(), jsonString.c_str()); + LOG_INFO("JSON publish message to %s, %u bytes: %s\n", topicJson.c_str(), jsonString.length(), + jsonString.c_str()); pubSub.publish(topicJson.c_str(), jsonString.c_str(), false); } } @@ -348,7 +361,8 @@ void MQTT::onSend(const MeshPacket &mp, ChannelIndex chIndex) auto jsonString = this->downstreamPacketToJson((MeshPacket *)&mp); if (jsonString.length() != 0) { String topicJson = jsonTopic + channelId + "/" + owner.id; - LOG_INFO("JSON publish message to %s, %u bytes: %s\n", topicJson.c_str(), jsonString.length(), jsonString.c_str()); + LOG_INFO("JSON publish message to %s, %u bytes: %s\n", topicJson.c_str(), jsonString.length(), + jsonString.c_str()); pubSub.publish(topicJson.c_str(), jsonString.c_str(), false); } } @@ -453,11 +467,17 @@ std::string MQTT::downstreamPacketToJson(MeshPacket *mp) memset(&scratch, 0, sizeof(scratch)); if (pb_decode_from_bytes(mp->decoded.payload.bytes, mp->decoded.payload.size, &Position_msg, &scratch)) { decoded = &scratch; - if((int)decoded->time){msgPayload["time"] = new JSONValue((int)decoded->time);} - if ((int)decoded->timestamp){msgPayload["timestamp"] = new JSONValue((int)decoded->timestamp);} + if ((int)decoded->time) { + msgPayload["time"] = new JSONValue((int)decoded->time); + } + if ((int)decoded->timestamp) { + msgPayload["timestamp"] = new JSONValue((int)decoded->timestamp); + } msgPayload["latitude_i"] = new JSONValue((int)decoded->latitude_i); msgPayload["longitude_i"] = new JSONValue((int)decoded->longitude_i); - if((int)decoded->altitude){msgPayload["altitude"] = new JSONValue((int)decoded->altitude);} + if ((int)decoded->altitude) { + msgPayload["altitude"] = new JSONValue((int)decoded->altitude); + } jsonObj["payload"] = new JSONValue(msgPayload); } else { LOG_ERROR("Error decoding protobuf for position message!\n"); diff --git a/src/mqtt/MQTT.h b/src/mqtt/MQTT.h index 16ce4c37a..3f2cf2de6 100644 --- a/src/mqtt/MQTT.h +++ b/src/mqtt/MQTT.h @@ -4,7 +4,7 @@ #include "concurrency/OSThread.h" #include "mesh/Channels.h" -#include "mesh/generated/mqtt.pb.h" +#include "mesh/generated/meshtastic/mqtt.pb.h" #include #if HAS_WIFI #include @@ -53,7 +53,7 @@ class MQTT : private concurrency::OSThread void reconnect(); bool connected(); - + protected: PointerQueue mqttQueue; @@ -80,7 +80,7 @@ class MQTT : private concurrency::OSThread std::string downstreamPacketToJson(MeshPacket *mp); /// Return 0 if sleep is okay, veto sleep if we are connected to pubsub server - // int preflightSleepCb(void *unused = NULL) { return pubSub.connected() ? 1 : 0; } + // int preflightSleepCb(void *unused = NULL) { return pubSub.connected() ? 1 : 0; } }; void mqttInit(); diff --git a/src/xmodem.cpp b/src/xmodem.cpp new file mode 100644 index 000000000..aed551795 --- /dev/null +++ b/src/xmodem.cpp @@ -0,0 +1,221 @@ +/*********************************************************************************************************************** + * based on XMODEM implementation by Georges Menie (www.menie.org) + *********************************************************************************************************************** + * Copyright 2001-2019 Georges Menie (www.menie.org) + * All rights reserved. + * + * Adapted for protobuf encapsulation. this is not really Xmodem any more. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the University of California, Berkeley nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + **********************************************************************************************************************/ + +#include "xmodem.h" + +XModemAdapter xModem; + +XModemAdapter::XModemAdapter() +{ + xmodemStore = (XModem *)malloc(XModem_size); +} + +unsigned short XModemAdapter::crc16_ccitt(const pb_byte_t *buffer, int length) +{ + unsigned short crc16 = 0; + while (length != 0) { + crc16 = (unsigned char)(crc16 >> 8) | (crc16 << 8); + crc16 ^= *buffer; + crc16 ^= (unsigned char)(crc16 & 0xff) >> 4; + crc16 ^= (crc16 << 8) << 4; + crc16 ^= ((crc16 & 0xff) << 4) << 1; + buffer++; + length--; + } + + return crc16; +} + +int XModemAdapter::check(const pb_byte_t *buf, int sz, unsigned short tcrc) +{ + unsigned short crc = crc16_ccitt(buf, sz); + if (crc == tcrc) + return 1; + else + return 0; +} + +void XModemAdapter::sendControl(XModem_Control c) +{ + memset(xmodemStore, 0, XModem_size); + xmodemStore->control = c; + LOG_DEBUG("XModem: Notify Sending control %d.\n", c); + packetReady.notifyObservers(packetno); +} + +XModem *XModemAdapter::getForPhone() +{ + if (xmodemStore) { + return xmodemStore; + } else { + return NULL; + } +} + +void XModemAdapter::handlePacket(XModem xmodemPacket) +{ + switch (xmodemPacket.control) { + case XModem_Control_SOH: + case XModem_Control_STX: + if ((xmodemPacket.seq == 0) && !isReceiving && !isTransmitting) { + // NULL packet has the destination filename + memcpy(filename, &xmodemPacket.buffer.bytes, xmodemPacket.buffer.size); + if (xmodemPacket.control == XModem_Control_SOH) { // Receive this file and put to Flash + file = FSCom.open(filename, FILE_O_WRITE); + if (file) { + sendControl(XModem_Control_ACK); + isReceiving = true; + packetno = 1; + break; + } + sendControl(XModem_Control_NAK); + isReceiving = false; + break; + } else { // Transmit this file from Flash + LOG_INFO("XModem: Transmitting file %s\n", filename); + file = FSCom.open(filename, FILE_O_READ); + if (file) { + packetno = 1; + isTransmitting = true; + memset(xmodemStore, 0, XModem_size); + xmodemStore->control = XModem_Control_SOH; + xmodemStore->seq = packetno; + xmodemStore->buffer.size = file.read(xmodemStore->buffer.bytes, sizeof(XModem_buffer_t::bytes)); + xmodemStore->crc16 = crc16_ccitt(xmodemStore->buffer.bytes, xmodemStore->buffer.size); + LOG_DEBUG("XModem: STX Notify Sending packet %d, %d Bytes.\n", packetno, xmodemStore->buffer.size); + if (xmodemStore->buffer.size < sizeof(XModem_buffer_t::bytes)) { + isEOT = true; + // send EOT on next Ack + } + packetReady.notifyObservers(packetno); + break; + } + sendControl(XModem_Control_NAK); + isTransmitting = false; + break; + } + } else { + if (isReceiving) { + // normal file data packet + if ((xmodemPacket.seq == packetno) && + check(xmodemPacket.buffer.bytes, xmodemPacket.buffer.size, xmodemPacket.crc16)) { + // valid packet + file.write(xmodemPacket.buffer.bytes, xmodemPacket.buffer.size); + sendControl(XModem_Control_ACK); + packetno++; + break; + } + // invalid packet + sendControl(XModem_Control_NAK); + break; + } else if (isTransmitting) { + // just received something weird. + sendControl(XModem_Control_CAN); + isTransmitting = false; + break; + } + } + break; + case XModem_Control_EOT: + // End of transmission + sendControl(XModem_Control_ACK); + file.close(); + isReceiving = false; + break; + case XModem_Control_CAN: + // Cancel transmission and remove file + sendControl(XModem_Control_ACK); + file.close(); + FSCom.remove(filename); + isReceiving = false; + break; + case XModem_Control_ACK: + // Acknowledge Send the next packet + if (isTransmitting) { + if (isEOT) { + sendControl(XModem_Control_EOT); + file.close(); + LOG_INFO("XModem: Finished sending file %s\n", filename); + isTransmitting = false; + isEOT = false; + break; + } + retrans = MAXRETRANS; // reset retransmit counter + packetno++; + memset(xmodemStore, 0, XModem_size); + xmodemStore->control = XModem_Control_SOH; + xmodemStore->seq = packetno; + xmodemStore->buffer.size = file.read(xmodemStore->buffer.bytes, sizeof(XModem_buffer_t::bytes)); + xmodemStore->crc16 = crc16_ccitt(xmodemStore->buffer.bytes, xmodemStore->buffer.size); + LOG_DEBUG("XModem: ACK Notify Sending packet %d, %d Bytes.\n", packetno, xmodemStore->buffer.size); + if (xmodemStore->buffer.size < sizeof(XModem_buffer_t::bytes)) { + isEOT = true; + // send EOT on next Ack + } + packetReady.notifyObservers(packetno); + } else { + // just received something weird. + sendControl(XModem_Control_CAN); + } + break; + case XModem_Control_NAK: + // Negative acknowledge. Send the same buffer again + if (isTransmitting) { + if (--retrans <= 0) { + sendControl(XModem_Control_CAN); + file.close(); + LOG_INFO("XModem: Retransmit timeout, cancelling file %s\n", filename); + isTransmitting = false; + break; + } + memset(xmodemStore, 0, XModem_size); + xmodemStore->control = XModem_Control_SOH; + xmodemStore->seq = packetno; + file.seek((packetno - 1) * sizeof(XModem_buffer_t::bytes)); + xmodemStore->buffer.size = file.read(xmodemStore->buffer.bytes, sizeof(XModem_buffer_t::bytes)); + xmodemStore->crc16 = crc16_ccitt(xmodemStore->buffer.bytes, xmodemStore->buffer.size); + LOG_DEBUG("XModem: NAK Notify Sending packet %d, %d Bytes.\n", packetno, xmodemStore->buffer.size); + if (xmodemStore->buffer.size < sizeof(XModem_buffer_t::bytes)) { + isEOT = true; + // send EOT on next Ack + } + packetReady.notifyObservers(packetno); + } else { + // just received something weird. + sendControl(XModem_Control_CAN); + } + break; + default: + // Unknown control character + break; + } +} diff --git a/src/xmodem.h b/src/xmodem.h new file mode 100644 index 000000000..8a9c08db6 --- /dev/null +++ b/src/xmodem.h @@ -0,0 +1,76 @@ +/*********************************************************************************************************************** + * based on XMODEM implementation by Georges Menie (www.menie.org) + *********************************************************************************************************************** + * Copyright 2001-2019 Georges Menie (www.menie.org) + * All rights reserved. + * + * Adapted for protobuf encapsulation. this is not really Xmodem any more. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the University of California, Berkeley nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + **********************************************************************************************************************/ + +#pragma once + +#include "FSCommon.h" +#include "configuration.h" +#include "mesh/generated/meshtastic/xmodem.pb.h" + +#define MAXRETRANS 25 + +class XModemAdapter +{ + public: + // Called when we put a fragment in the outgoing memory + Observable packetReady; + + XModemAdapter(); + + void handlePacket(XModem xmodemPacket); + XModem *getForPhone(); + + private: + bool isReceiving = false; + bool isTransmitting = false; + bool isEOT = false; + + int retrans = MAXRETRANS; + + uint16_t packetno = 0; + +#ifdef ARCH_NRF52 + File file = File(FSCom); +#else + File file; +#endif + + char filename[sizeof(XModem_buffer_t::bytes)] = {0}; + + protected: + XModem *xmodemStore = NULL; + unsigned short crc16_ccitt(const pb_byte_t *buffer, int length); + int check(const pb_byte_t *buf, int sz, unsigned short tcrc); + void sendControl(XModem_Control c); +}; + +extern XModemAdapter xModem;