From 366a02850279aa1ee25d1988415badbe6baa6264 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 26 Dec 2021 09:05:35 -0800 Subject: [PATCH 01/17] Remove unused comments. --- src/mesh/http/WebServer.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/mesh/http/WebServer.cpp b/src/mesh/http/WebServer.cpp index 500af5107..e450c566b 100644 --- a/src/mesh/http/WebServer.cpp +++ b/src/mesh/http/WebServer.cpp @@ -114,22 +114,12 @@ static void taskCreateCert(void *parameter) if (createCertResult != 0) { DEBUG_MSG("Creating the certificate failed\n"); - // Serial.printf("Creating the certificate failed. Error Code = 0x%02X, check SSLCert.hpp for details", - // createCertResult); - // while (true) - // delay(500); } else { DEBUG_MSG("Creating the certificate was successful\n"); DEBUG_MSG("Created Private Key: %d Bytes\n", cert->getPKLength()); - // for (int i = 0; i < cert->getPKLength(); i++) - // Serial.print(cert->getPKData()[i], HEX); - // Serial.println(); DEBUG_MSG("Created Certificate: %d Bytes\n", cert->getCertLength()); - // for (int i = 0; i < cert->getCertLength(); i++) - // Serial.print(cert->getCertData()[i], HEX); - // Serial.println(); prefs.putBytes("PK", (uint8_t *)cert->getPKData(), cert->getPKLength()); prefs.putBytes("cert", (uint8_t *)cert->getCertData(), cert->getCertLength()); From 072707c77e996f92e9f362caceddd30598fa95e2 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sun, 26 Dec 2021 09:08:49 -0800 Subject: [PATCH 02/17] Update esp8266-oled-ssd1306 --- platformio.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platformio.ini b/platformio.ini index 8d4f3a883..a3ab41283 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,7 +9,7 @@ ; https://docs.platformio.org/page/projectconf.html [platformio] -;default_envs = tbeam +default_envs = tbeam ;default_envs = tbeam0.7 ;default_envs = heltec-v2.0 ;default_envs = tlora-v1 @@ -21,7 +21,7 @@ ;default_envs = native # lora-relay-v1 # nrf52840dk-geeksville # linux # or if you'd like to change the default to something like lora-relay-v1 put that here ;default_envs = rak4631 ;default_envs = rak4630 -default_envs = meshtastic-diy-v1 +;default_envs = meshtastic-diy-v1 [common] ; common is not currently used @@ -68,7 +68,7 @@ debug_tool = jlink ; monitor adapter_khz 10000 lib_deps = - https://github.com/meshtastic/esp8266-oled-ssd1306.git#35d796226b853b0c0ff818b2f1aa3d35e7296a96 ; ESP8266_SSD1306 + https://github.com/meshtastic/esp8266-oled-ssd1306.git#03c0015fc4621f7a76390fa6846de41380f1f9f9 ; ESP8266_SSD1306 https://github.com/meshtastic/OneButton.git#3bcba9492d01e2a8a86f46700ab16f96dd2cf1f5 ; OneButton library for non-blocking button debounce 1202 ; CRC32, explicitly needed because dependency is missing in the ble ota update lib https://github.com/meshtastic/arduino-fsm.git @@ -124,7 +124,7 @@ platform_packages = framework-arduinoespressif32@https://github.com/meshtastic/arduino-esp32.git#4cde0f5d412d2695184f32e8a47e9bea57b45276 ; leave this commented out to avoid breaking Windows -upload_port = /dev/ttyUSB0 +;upload_port = /dev/ttyUSB0 ;monitor_port = /dev/ttyUSB0 ;upload_port = /dev/cu.SLAB_USBtoUART From a70b849039ad2049efd2a304a269b7f854509c77 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Tue, 28 Dec 2021 11:20:45 -0600 Subject: [PATCH 03/17] Changed getMacAddr behavior (#1017) --- src/nrf52/main-nrf52.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/nrf52/main-nrf52.cpp b/src/nrf52/main-nrf52.cpp index ab109205b..88166e4fa 100644 --- a/src/nrf52/main-nrf52.cpp +++ b/src/nrf52/main-nrf52.cpp @@ -38,18 +38,13 @@ void __attribute__((noreturn)) __assert_func(const char *file, int line, const c void getMacAddr(uint8_t *dmac) { - ble_gap_addr_t addr; - if (sd_ble_gap_addr_get(&addr) == NRF_SUCCESS) { - memcpy(dmac, addr.addr, 6); - } else { - const uint8_t *src = (const uint8_t *)NRF_FICR->DEVICEADDR; - dmac[5] = src[0]; - dmac[4] = src[1]; - dmac[3] = src[2]; - dmac[2] = src[3]; - dmac[1] = src[4]; - dmac[0] = src[5] | 0xc0; // MSB high two bits get set elsewhere in the bluetooth stack - } + const uint8_t *src = (const uint8_t *)NRF_FICR->DEVICEADDR; + dmac[5] = src[0]; + dmac[4] = src[1]; + dmac[3] = src[2]; + dmac[2] = src[3]; + dmac[1] = src[4]; + dmac[0] = src[5] | 0xc0; // MSB high two bits get set elsewhere in the bluetooth stack } static void initBrownout() From 106341529285e00364456cd1982258a612c36e11 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Tue, 28 Dec 2021 14:17:56 -0600 Subject: [PATCH 04/17] Remove networking operations from presentation layer (#1033) * Remove networking operations from presentation layer --- src/graphics/Screen.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 246fcea5f..502c60b02 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -619,11 +619,6 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_ n = nodeDB.getNodeByIndex(nodeIndex); } displayedNodeNum = n->num; - - // We just changed to a new node screen, ask that node for updated state if it's older than 2 minutes - if (sinceLastSeen(n) > 120) { - service.sendNetworkPing(displayedNodeNum, true); - } } NodeInfo *node = nodeDB.getNodeByIndex(nodeIndex); From 638d43a34121a351f58c1c4818b962d502eface9 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Tue, 28 Dec 2021 16:40:53 -0800 Subject: [PATCH 05/17] Roll back oled update --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index a3ab41283..1d35ddeb9 100644 --- a/platformio.ini +++ b/platformio.ini @@ -68,7 +68,7 @@ debug_tool = jlink ; monitor adapter_khz 10000 lib_deps = - https://github.com/meshtastic/esp8266-oled-ssd1306.git#03c0015fc4621f7a76390fa6846de41380f1f9f9 ; ESP8266_SSD1306 + https://github.com/meshtastic/esp8266-oled-ssd1306.git#35d796226b853b0c0ff818b2f1aa3d35e7296a96 ; ESP8266_SSD1306 https://github.com/meshtastic/OneButton.git#3bcba9492d01e2a8a86f46700ab16f96dd2cf1f5 ; OneButton library for non-blocking button debounce 1202 ; CRC32, explicitly needed because dependency is missing in the ble ota update lib https://github.com/meshtastic/arduino-fsm.git From a2883789d1489343e720eb17d104501aa982d691 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Tue, 28 Dec 2021 23:29:30 -0800 Subject: [PATCH 06/17] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index c52c8ef99..638783bad 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit c52c8ef99ead88a5edb73891b33247c54d37cb28 +Subproject commit 638783bad47d683a5bd67f8f53091c8905e4402d From f1c029d6dad9183584adc9791df8ed0650a361b7 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Tue, 28 Dec 2021 23:33:12 -0800 Subject: [PATCH 07/17] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index 638783bad..ec35525ae 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 638783bad47d683a5bd67f8f53091c8905e4402d +Subproject commit ec35525ae6042999b2b3de368aff0ebc3fdcf308 From 10dc8233ea3150c0bac4364e09ca306addb10e10 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Tue, 28 Dec 2021 23:34:49 -0800 Subject: [PATCH 08/17] Initial checkin for Airtime Utilization https://github.com/meshtastic/Meshtastic-device/issues/1034 --- src/airtime.cpp | 73 +++++++++++++++++++++----------- src/airtime.h | 26 ++++++++---- src/graphics/Screen.cpp | 10 ++--- src/mesh/http/ContentHandler.cpp | 18 ++++---- 4 files changed, 79 insertions(+), 48 deletions(-) diff --git a/src/airtime.cpp b/src/airtime.cpp index 683b8f2c0..657f72689 100644 --- a/src/airtime.cpp +++ b/src/airtime.cpp @@ -1,17 +1,11 @@ -#include "configuration.h" #include "airtime.h" #include "NodeDB.h" +#include "configuration.h" #define periodsToLog 24 AirTime *airTime; -uint32_t secondsPerPeriod = 3600; -uint32_t lastMillis = 0; -uint32_t secSinceBoot = 0; - -// AirTime at; - // Don't read out of this directly. Use the helper functions. struct airtimeStruct { uint32_t periodTX[periodsToLog]; // AirTime transmitted @@ -36,14 +30,17 @@ void AirTime::logAirtime(reportTypes reportType, uint32_t airtime_ms) } else { DEBUG_MSG("AirTime - Unknown report time. This should never happen!!\n"); } + + uint8_t channelUtilPeriod = (getSecondsSinceBoot() / 10) % CHANNEL_UTILIZATION_PERIODS; + this->channelUtilization[channelUtilPeriod] = channelUtilization[channelUtilPeriod] + airtime_ms; } -uint8_t currentPeriodIndex() +uint8_t AirTime::currentPeriodIndex() { - return ((getSecondsSinceBoot() / secondsPerPeriod) % periodsToLog); + return ((getSecondsSinceBoot() / SECONDS_PER_PERIOD) % periodsToLog); } -void airtimeRotatePeriod() +void AirTime::airtimeRotatePeriod() { if (airtimes.lastPeriodIndex != currentPeriodIndex()) { @@ -64,7 +61,6 @@ void airtimeRotatePeriod() myNodeInfo.air_period_tx[0] = 0; myNodeInfo.air_period_rx[0] = 0; - airtimes.lastPeriodIndex = currentPeriodIndex(); } } @@ -82,36 +78,63 @@ uint32_t *airtimeReport(reportTypes reportType) return 0; } -uint8_t getPeriodsToLog() +uint8_t AirTime::getPeriodsToLog() { return periodsToLog; } -uint32_t getSecondsPerPeriod() +uint32_t AirTime::getSecondsPerPeriod() { - return secondsPerPeriod; + return SECONDS_PER_PERIOD; } -uint32_t getSecondsSinceBoot() +uint32_t AirTime::getSecondsSinceBoot() { - return secSinceBoot; + return this->secSinceBoot; +} + +float AirTime::channelUtilizationPercent() +{ + uint32_t sum = 0; + for (uint32_t i = 0; i < CHANNEL_UTILIZATION_PERIODS; i++) { + sum += this->channelUtilization[i]; + // DEBUG_MSG("ChanUtilArray %u %u\n", i, this->channelUtilization[i]); + } + + return (float(sum) / float(CHANNEL_UTILIZATION_PERIODS * 10 * 1000)) * 100; } AirTime::AirTime() : concurrency::OSThread("AirTime") {} int32_t AirTime::runOnce() { - //DEBUG_MSG("AirTime::runOnce()\n"); - - airtimeRotatePeriod(); secSinceBoot++; - /* - This actually doesn't need to be run once per second but we currently use it for the - secSinceBoot counter. + uint8_t utilPeriod = (getSecondsSinceBoot() / 10) % CHANNEL_UTILIZATION_PERIODS; + + if (firstTime) { + // DEBUG_MSG("AirTime::runOnce()\n"); + + airtimeRotatePeriod(); + + for (uint32_t i = 0; i < CHANNEL_UTILIZATION_PERIODS; i++) { + this->channelUtilization[i] = 0; + } + + firstTime = false; + lastUtilPeriod = utilPeriod; + + } else { + + // Reset the channelUtilization window when we roll over + if (lastUtilPeriod != utilPeriod) { + lastUtilPeriod = utilPeriod; + + this->channelUtilization[utilPeriod] = 0; + } + + DEBUG_MSG("Channel Utilization percent %3.1f\n", airTime->channelUtilizationPercent()); + } - If we have a better counter of how long the device has been online (and not millis()) - then we can change this to something less frequent. Maybe once ever 5 seconds? - */ return (1000 * 1); } \ No newline at end of file diff --git a/src/airtime.h b/src/airtime.h index 134bad47d..9c67759c3 100644 --- a/src/airtime.h +++ b/src/airtime.h @@ -23,21 +23,16 @@ RX_ALL_LOG - RX_LOG = Other lora radios on our frequency channel. */ + +#define CHANNEL_UTILIZATION_PERIODS 6 +#define SECONDS_PER_PERIOD 3600 + enum reportTypes { TX_LOG, RX_LOG, RX_ALL_LOG }; void logAirtime(reportTypes reportType, uint32_t airtime_ms); -void airtimeRotatePeriod(); - -uint8_t currentPeriodIndex(); -uint8_t getPeriodsToLog(); - -uint32_t getSecondsSinceBoot(); - uint32_t *airtimeReport(reportTypes reportType); -uint32_t getSecondsPerPeriod(); - class AirTime : private concurrency::OSThread { @@ -45,6 +40,19 @@ class AirTime : private concurrency::OSThread AirTime(); void logAirtime(reportTypes reportType, uint32_t airtime_ms); + float channelUtilizationPercent(); + uint32_t channelUtilization[CHANNEL_UTILIZATION_PERIODS]; + + uint8_t currentPeriodIndex(); + void airtimeRotatePeriod(); + uint8_t getPeriodsToLog(); + uint32_t getSecondsPerPeriod(); + uint32_t getSecondsSinceBoot(); + + private: + bool firstTime = true; + uint8_t lastUtilPeriod = 0; + uint32_t secSinceBoot = 0; protected: virtual int32_t runOnce() override; diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 502c60b02..cdf5ab1a5 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -1398,11 +1398,11 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat display->drawString(x, y + FONT_HEIGHT_SMALL * 1, uptime); -#ifndef NO_ESP32 - // Show CPU Frequency. - display->drawString(x + SCREEN_WIDTH - display->getStringWidth("CPU " + String(getCpuFrequencyMhz()) + "MHz"), - y + FONT_HEIGHT_SMALL * 1, "CPU " + String(getCpuFrequencyMhz()) + "MHz"); -#endif + // Display Channel Utilization + char chUtil[13]; + sprintf(chUtil, "ChUtil %2.0f%%", airTime->channelUtilizationPercent()); + display->drawString(x + SCREEN_WIDTH - display->getStringWidth(chUtil), + y + FONT_HEIGHT_SMALL * 1, chUtil); // Line 3 if (radioConfig.preferences.gps_format != GpsCoordinateFormat_GpsFormatDMS) // if DMS then don't draw altitude diff --git a/src/mesh/http/ContentHandler.cpp b/src/mesh/http/ContentHandler.cpp index 4174c0a23..b5ac29500 100644 --- a/src/mesh/http/ContentHandler.cpp +++ b/src/mesh/http/ContentHandler.cpp @@ -503,11 +503,11 @@ void handleReport(HTTPRequest *req, HTTPResponse *res) res->print("\"tx_log\": ["); logArray = airtimeReport(TX_LOG); - for (int i = 0; i < getPeriodsToLog(); i++) { + for (int i = 0; i < airTime->getPeriodsToLog(); i++) { uint32_t tmp; tmp = *(logArray + i); res->printf("%d", tmp); - if (i != getPeriodsToLog() - 1) { + if (i != airTime->getPeriodsToLog() - 1) { res->print(", "); } } @@ -516,11 +516,11 @@ void handleReport(HTTPRequest *req, HTTPResponse *res) res->print("\"rx_log\": ["); logArray = airtimeReport(RX_LOG); - for (int i = 0; i < getPeriodsToLog(); i++) { + for (int i = 0; i < airTime->getPeriodsToLog(); i++) { uint32_t tmp; tmp = *(logArray + i); res->printf("%d", tmp); - if (i != getPeriodsToLog() - 1) { + if (i != airTime->getPeriodsToLog() - 1) { res->print(", "); } } @@ -529,19 +529,19 @@ void handleReport(HTTPRequest *req, HTTPResponse *res) res->print("\"rx_all_log\": ["); logArray = airtimeReport(RX_ALL_LOG); - for (int i = 0; i < getPeriodsToLog(); i++) { + for (int i = 0; i < airTime->getPeriodsToLog(); i++) { uint32_t tmp; tmp = *(logArray + i); res->printf("%d", tmp); - if (i != getPeriodsToLog() - 1) { + if (i != airTime->getPeriodsToLog() - 1) { res->print(", "); } } res->println("],"); - res->printf("\"seconds_since_boot\": %u,\n", getSecondsSinceBoot()); - res->printf("\"seconds_per_period\": %u,\n", getSecondsPerPeriod()); - res->printf("\"periods_to_log\": %u\n", getPeriodsToLog()); + res->printf("\"seconds_since_boot\": %u,\n", airTime->getSecondsSinceBoot()); + res->printf("\"seconds_per_period\": %u,\n", airTime->getSecondsPerPeriod()); + res->printf("\"periods_to_log\": %u\n", airTime->getPeriodsToLog()); res->println("},"); From 79e75a47f6e1c445061cdfa7209152498d6de32a Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Tue, 28 Dec 2021 23:37:23 -0800 Subject: [PATCH 09/17] Add channel utilization to myNodeInfo --- src/airtime.cpp | 5 ++++- src/mesh/generated/admin.pb.h | 2 +- src/mesh/generated/deviceonly.pb.h | 2 +- src/mesh/generated/mesh.pb.h | 13 ++++++++----- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/airtime.cpp b/src/airtime.cpp index 657f72689..62033d847 100644 --- a/src/airtime.cpp +++ b/src/airtime.cpp @@ -133,7 +133,10 @@ int32_t AirTime::runOnce() this->channelUtilization[utilPeriod] = 0; } - DEBUG_MSG("Channel Utilization percent %3.1f\n", airTime->channelUtilizationPercent()); + // Update channel_utilization every second. + myNodeInfo.channel_utilization = airTime->channelUtilizationPercent(); + + //DEBUG_MSG("Channel Utilization percent %3.1f\n", airTime->channelUtilizationPercent()); } return (1000 * 1); diff --git a/src/mesh/generated/admin.pb.h b/src/mesh/generated/admin.pb.h index 08c647aea..ebc6fc9a0 100644 --- a/src/mesh/generated/admin.pb.h +++ b/src/mesh/generated/admin.pb.h @@ -86,7 +86,7 @@ extern const pb_msgdesc_t AdminMessage_msg; #define AdminMessage_fields &AdminMessage_msg /* Maximum encoded size of messages (where known) */ -#define AdminMessage_size 461 +#define AdminMessage_size 529 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/deviceonly.pb.h b/src/mesh/generated/deviceonly.pb.h index 2d4e53f0c..284aa68f7 100644 --- a/src/mesh/generated/deviceonly.pb.h +++ b/src/mesh/generated/deviceonly.pb.h @@ -125,7 +125,7 @@ extern const pb_msgdesc_t ChannelFile_msg; /* Maximum encoded size of messages (where known) */ #define LegacyRadioConfig_size 4 #define LegacyRadioConfig_LegacyPreferences_size 2 -#define DeviceState_size 9943 +#define DeviceState_size 9949 #define ChannelFile_size 832 #ifdef __cplusplus diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index 8f4a7ffbc..7419ac023 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -164,6 +164,7 @@ typedef struct _MyNodeInfo { pb_size_t air_period_rx_count; uint32_t air_period_rx[24]; bool has_wifi; + float channel_utilization; } MyNodeInfo; typedef struct _Position { @@ -332,7 +333,7 @@ extern "C" { #define Data_init_default {_PortNum_MIN, {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} -#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, 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, 0, 0, 0}, 0} +#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, 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, 0, 0, 0}, 0, 0} #define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN} #define FromRadio_init_default {0, 0, {MyNodeInfo_init_default}} #define ToRadio_init_default {0, {MeshPacket_init_default}} @@ -344,7 +345,7 @@ extern "C" { #define Data_init_zero {_PortNum_MIN, {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} -#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, 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, 0, 0, 0}, 0} +#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, 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, 0, 0, 0}, 0, 0} #define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN} #define FromRadio_init_zero {0, 0, {MyNodeInfo_init_zero}} #define ToRadio_init_zero {0, {MeshPacket_init_zero}} @@ -378,6 +379,7 @@ extern "C" { #define MyNodeInfo_air_period_tx_tag 16 #define MyNodeInfo_air_period_rx_tag 17 #define MyNodeInfo_has_wifi_tag 18 +#define MyNodeInfo_channel_utilization_tag 19 #define Position_latitude_i_tag 1 #define Position_longitude_i_tag 2 #define Position_altitude_tag 3 @@ -559,7 +561,8 @@ X(a, STATIC, SINGULAR, UINT32, min_app_version, 14) \ X(a, STATIC, SINGULAR, UINT32, max_channels, 15) \ X(a, STATIC, REPEATED, UINT32, air_period_tx, 16) \ X(a, STATIC, REPEATED, UINT32, air_period_rx, 17) \ -X(a, STATIC, SINGULAR, BOOL, has_wifi, 18) +X(a, STATIC, SINGULAR, BOOL, has_wifi, 18) \ +X(a, STATIC, SINGULAR, FLOAT, channel_utilization, 19) #define MyNodeInfo_CALLBACK NULL #define MyNodeInfo_DEFAULT NULL @@ -637,9 +640,9 @@ extern const pb_msgdesc_t ToRadio_PeerInfo_msg; #define Data_size 260 #define MeshPacket_size 311 #define NodeInfo_size 270 -#define MyNodeInfo_size 445 +#define MyNodeInfo_size 451 #define LogRecord_size 81 -#define FromRadio_size 454 +#define FromRadio_size 460 #define ToRadio_size 314 #define ToRadio_PeerInfo_size 8 From 672ea5b494f559e80d2015c65868820fe1979048 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 29 Dec 2021 00:12:32 -0800 Subject: [PATCH 10/17] Removed radio config that shouldn't be there. --- src/plugins/PositionPlugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/PositionPlugin.cpp b/src/plugins/PositionPlugin.cpp index e10f05d1e..0a3a412d7 100644 --- a/src/plugins/PositionPlugin.cpp +++ b/src/plugins/PositionPlugin.cpp @@ -127,7 +127,7 @@ int32_t PositionPlugin::runOnce() { NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum()); - radioConfig.preferences.position_broadcast_smart = true; + //radioConfig.preferences.position_broadcast_smart = true; // We limit our GPS broadcasts to a max rate uint32_t now = millis(); From 37dec91ed9c1abf25310ced96a3345573a16f097 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 29 Dec 2021 00:36:15 -0800 Subject: [PATCH 11/17] Rename periods to log --- src/airtime.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/airtime.cpp b/src/airtime.cpp index 62033d847..31947282c 100644 --- a/src/airtime.cpp +++ b/src/airtime.cpp @@ -2,15 +2,15 @@ #include "NodeDB.h" #include "configuration.h" -#define periodsToLog 24 +#define PERIODS_TO_LOG 24 AirTime *airTime; // Don't read out of this directly. Use the helper functions. struct airtimeStruct { - uint32_t periodTX[periodsToLog]; // AirTime transmitted - uint32_t periodRX[periodsToLog]; // AirTime received and repeated (Only valid mesh packets) - uint32_t periodRX_ALL[periodsToLog]; // AirTime received regardless of valid mesh packet. Could include noise. + uint32_t periodTX[PERIODS_TO_LOG]; // AirTime transmitted + uint32_t periodRX[PERIODS_TO_LOG]; // AirTime received and repeated (Only valid mesh packets) + uint32_t periodRX_ALL[PERIODS_TO_LOG]; // AirTime received regardless of valid mesh packet. Could include noise. uint8_t lastPeriodIndex; } airtimes; @@ -37,7 +37,7 @@ void AirTime::logAirtime(reportTypes reportType, uint32_t airtime_ms) uint8_t AirTime::currentPeriodIndex() { - return ((getSecondsSinceBoot() / SECONDS_PER_PERIOD) % periodsToLog); + return ((getSecondsSinceBoot() / SECONDS_PER_PERIOD) % PERIODS_TO_LOG); } void AirTime::airtimeRotatePeriod() @@ -46,7 +46,7 @@ void AirTime::airtimeRotatePeriod() if (airtimes.lastPeriodIndex != currentPeriodIndex()) { DEBUG_MSG("Rotating airtimes to a new period = %u\n", currentPeriodIndex()); - for (int i = periodsToLog - 2; i >= 0; --i) { + for (int i = PERIODS_TO_LOG - 2; i >= 0; --i) { airtimes.periodTX[i + 1] = airtimes.periodTX[i]; airtimes.periodRX[i + 1] = airtimes.periodRX[i]; airtimes.periodRX_ALL[i + 1] = airtimes.periodRX_ALL[i]; @@ -80,7 +80,7 @@ uint32_t *airtimeReport(reportTypes reportType) uint8_t AirTime::getPeriodsToLog() { - return periodsToLog; + return PERIODS_TO_LOG; } uint32_t AirTime::getSecondsPerPeriod() @@ -113,8 +113,6 @@ int32_t AirTime::runOnce() uint8_t utilPeriod = (getSecondsSinceBoot() / 10) % CHANNEL_UTILIZATION_PERIODS; if (firstTime) { - // DEBUG_MSG("AirTime::runOnce()\n"); - airtimeRotatePeriod(); for (uint32_t i = 0; i < CHANNEL_UTILIZATION_PERIODS; i++) { @@ -135,8 +133,6 @@ int32_t AirTime::runOnce() // Update channel_utilization every second. myNodeInfo.channel_utilization = airTime->channelUtilizationPercent(); - - //DEBUG_MSG("Channel Utilization percent %3.1f\n", airTime->channelUtilizationPercent()); } return (1000 * 1); From 7eb00dd5f67901b1a88ec90c889adec74e525476 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 29 Dec 2021 00:36:54 -0800 Subject: [PATCH 12/17] Remove unknown report type --- src/airtime.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/airtime.cpp b/src/airtime.cpp index 31947282c..9dff7ad0b 100644 --- a/src/airtime.cpp +++ b/src/airtime.cpp @@ -27,8 +27,6 @@ void AirTime::logAirtime(reportTypes reportType, uint32_t airtime_ms) } else if (reportType == RX_ALL_LOG) { DEBUG_MSG("AirTime - Packet received (noise?) : %ums\n", airtime_ms); airtimes.periodRX_ALL[0] = airtimes.periodRX_ALL[0] + airtime_ms; - } else { - DEBUG_MSG("AirTime - Unknown report time. This should never happen!!\n"); } uint8_t channelUtilPeriod = (getSecondsSinceBoot() / 10) % CHANNEL_UTILIZATION_PERIODS; From bdacd97feafced19a06cd29728ab9775b1790a6c Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 29 Dec 2021 00:45:36 -0800 Subject: [PATCH 13/17] Move airtimes struct into the class --- src/airtime.cpp | 42 +++++++++++++++----------------- src/airtime.h | 10 ++++++++ src/mesh/http/ContentHandler.cpp | 6 ++--- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/src/airtime.cpp b/src/airtime.cpp index 9dff7ad0b..3f744d4ac 100644 --- a/src/airtime.cpp +++ b/src/airtime.cpp @@ -2,31 +2,28 @@ #include "NodeDB.h" #include "configuration.h" -#define PERIODS_TO_LOG 24 AirTime *airTime; // Don't read out of this directly. Use the helper functions. -struct airtimeStruct { - uint32_t periodTX[PERIODS_TO_LOG]; // AirTime transmitted - uint32_t periodRX[PERIODS_TO_LOG]; // AirTime received and repeated (Only valid mesh packets) - uint32_t periodRX_ALL[PERIODS_TO_LOG]; // AirTime received regardless of valid mesh packet. Could include noise. - uint8_t lastPeriodIndex; -} airtimes; + void AirTime::logAirtime(reportTypes reportType, uint32_t airtime_ms) { + + // TODO: Is the airtimes array still necessary? It's now in myNodeInfo anyway + if (reportType == TX_LOG) { DEBUG_MSG("AirTime - Packet transmitted : %ums\n", airtime_ms); - airtimes.periodTX[0] = airtimes.periodTX[0] + airtime_ms; + this->airtimes.periodTX[0] = this->airtimes.periodTX[0] + airtime_ms; myNodeInfo.air_period_tx[0] = myNodeInfo.air_period_tx[0] + airtime_ms; } else if (reportType == RX_LOG) { DEBUG_MSG("AirTime - Packet received : %ums\n", airtime_ms); - airtimes.periodRX[0] = airtimes.periodRX[0] + airtime_ms; + this->airtimes.periodRX[0] = this->airtimes.periodRX[0] + airtime_ms; myNodeInfo.air_period_rx[0] = myNodeInfo.air_period_rx[0] + airtime_ms; } else if (reportType == RX_ALL_LOG) { DEBUG_MSG("AirTime - Packet received (noise?) : %ums\n", airtime_ms); - airtimes.periodRX_ALL[0] = airtimes.periodRX_ALL[0] + airtime_ms; + this->airtimes.periodRX_ALL[0] = this->airtimes.periodRX_ALL[0] + airtime_ms; } uint8_t channelUtilPeriod = (getSecondsSinceBoot() / 10) % CHANNEL_UTILIZATION_PERIODS; @@ -41,37 +38,38 @@ uint8_t AirTime::currentPeriodIndex() void AirTime::airtimeRotatePeriod() { - if (airtimes.lastPeriodIndex != currentPeriodIndex()) { + if (this->airtimes.lastPeriodIndex != currentPeriodIndex()) { DEBUG_MSG("Rotating airtimes to a new period = %u\n", currentPeriodIndex()); for (int i = PERIODS_TO_LOG - 2; i >= 0; --i) { - airtimes.periodTX[i + 1] = airtimes.periodTX[i]; - airtimes.periodRX[i + 1] = airtimes.periodRX[i]; - airtimes.periodRX_ALL[i + 1] = airtimes.periodRX_ALL[i]; + this->airtimes.periodTX[i + 1] = this->airtimes.periodTX[i]; + this->airtimes.periodRX[i + 1] = this->airtimes.periodRX[i]; + this->airtimes.periodRX_ALL[i + 1] = this->airtimes.periodRX_ALL[i]; myNodeInfo.air_period_tx[i + 1] = myNodeInfo.air_period_tx[i]; myNodeInfo.air_period_rx[i + 1] = myNodeInfo.air_period_rx[i]; } - airtimes.periodTX[0] = 0; - airtimes.periodRX[0] = 0; - airtimes.periodRX_ALL[0] = 0; + + this->airtimes.periodTX[0] = 0; + this->airtimes.periodRX[0] = 0; + this->airtimes.periodRX_ALL[0] = 0; myNodeInfo.air_period_tx[0] = 0; myNodeInfo.air_period_rx[0] = 0; - airtimes.lastPeriodIndex = currentPeriodIndex(); + this->airtimes.lastPeriodIndex = currentPeriodIndex(); } } -uint32_t *airtimeReport(reportTypes reportType) +uint32_t *AirTime::airtimeReport(reportTypes reportType) { if (reportType == TX_LOG) { - return airtimes.periodTX; + return this->airtimes.periodTX; } else if (reportType == RX_LOG) { - return airtimes.periodRX; + return this->airtimes.periodRX; } else if (reportType == RX_ALL_LOG) { - return airtimes.periodRX_ALL; + return this->airtimes.periodRX_ALL; } return 0; } diff --git a/src/airtime.h b/src/airtime.h index 9c67759c3..bf78ac3a9 100644 --- a/src/airtime.h +++ b/src/airtime.h @@ -26,6 +26,8 @@ #define CHANNEL_UTILIZATION_PERIODS 6 #define SECONDS_PER_PERIOD 3600 +#define PERIODS_TO_LOG 24 + enum reportTypes { TX_LOG, RX_LOG, RX_ALL_LOG }; @@ -48,12 +50,20 @@ class AirTime : private concurrency::OSThread uint8_t getPeriodsToLog(); uint32_t getSecondsPerPeriod(); uint32_t getSecondsSinceBoot(); + uint32_t *airtimeReport(reportTypes reportType); private: bool firstTime = true; uint8_t lastUtilPeriod = 0; uint32_t secSinceBoot = 0; + struct airtimeStruct { + uint32_t periodTX[PERIODS_TO_LOG]; // AirTime transmitted + uint32_t periodRX[PERIODS_TO_LOG]; // AirTime received and repeated (Only valid mesh packets) + uint32_t periodRX_ALL[PERIODS_TO_LOG]; // AirTime received regardless of valid mesh packet. Could include noise. + uint8_t lastPeriodIndex; + } airtimes; + protected: virtual int32_t runOnce() override; }; diff --git a/src/mesh/http/ContentHandler.cpp b/src/mesh/http/ContentHandler.cpp index b5ac29500..c1fced6de 100644 --- a/src/mesh/http/ContentHandler.cpp +++ b/src/mesh/http/ContentHandler.cpp @@ -502,7 +502,7 @@ void handleReport(HTTPRequest *req, HTTPResponse *res) res->print("\"tx_log\": ["); - logArray = airtimeReport(TX_LOG); + logArray = airTime->airtimeReport(TX_LOG); for (int i = 0; i < airTime->getPeriodsToLog(); i++) { uint32_t tmp; tmp = *(logArray + i); @@ -515,7 +515,7 @@ void handleReport(HTTPRequest *req, HTTPResponse *res) res->println("],"); res->print("\"rx_log\": ["); - logArray = airtimeReport(RX_LOG); + logArray = airTime->airtimeReport(RX_LOG); for (int i = 0; i < airTime->getPeriodsToLog(); i++) { uint32_t tmp; tmp = *(logArray + i); @@ -528,7 +528,7 @@ void handleReport(HTTPRequest *req, HTTPResponse *res) res->println("],"); res->print("\"rx_all_log\": ["); - logArray = airtimeReport(RX_ALL_LOG); + logArray = airTime->airtimeReport(RX_ALL_LOG); for (int i = 0; i < airTime->getPeriodsToLog(); i++) { uint32_t tmp; tmp = *(logArray + i); From 6f3ffc6ef075fa94ca6cec288e3d91a0789c56a3 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 29 Dec 2021 00:52:21 -0800 Subject: [PATCH 14/17] Delete build-nightly.sh Nightly build server has been decomissioned. --- bin/build-nightly.sh | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100755 bin/build-nightly.sh diff --git a/bin/build-nightly.sh b/bin/build-nightly.sh deleted file mode 100755 index de31c6ed1..000000000 --- a/bin/build-nightly.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -source ~/.bashrc - -# Meshtastic Nightly Build Script. -# McHamster (jm@casler.org) -# -# This is the script that is used for the nightly build server. -# -# It's probably not useful for most people, but you may want to run your own -# nightly builds. -# -# The last line of ~/.bashrc contains an inclusion of platformio in the path. -# Without this, the build script won't run from the crontab: -# -# export PATH="$HOME/.platformio/penv/bin:$PATH" -# -# The crontab contains: -# 0 2 * * * cd ~/meshtastic/github/meshtastic && source "~/.bashrc"; ./build-nightly.sh > ~/cronout.txt 2> ~/cronout.txt - -cd Meshtastic-device - -git pull - -bin/build-all.sh - -date_stamp=$(date +'%Y-%m-%d') - -cd .. - -# TODO: Archive the same binaries used by the build-all script. -#zip -r meshtastic_device_nightly_${date_stamp} Meshtastic-device/release/latest/bins -cp Meshtastic-device/release/archive/`ls -t ./Meshtastic-device/release/archive/| head -1` meshtastic_device_nightly_${date_stamp}.zip - -# Copy the file to the webserver -scp meshtastic_device_nightly_${date_stamp}.zip jm@10.11.12.20:/volume1/web/meshtastic/nightly_builds/ - -# Delete the local copy -rm meshtastic_device_nightly_${date_stamp}.zip From 68c52a8d368670226ebebd7263927db3c0d9d2a8 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 29 Dec 2021 09:22:47 -0800 Subject: [PATCH 15/17] updating proto submodule to latest --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index ec35525ae..1d3b4806a 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit ec35525ae6042999b2b3de368aff0ebc3fdcf308 +Subproject commit 1d3b4806ab5dc4b8ab62063dbb5799ab900464e6 From 7c6d53f297a3d38b5c37f39815c5397102da4de3 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 29 Dec 2021 09:25:01 -0800 Subject: [PATCH 16/17] Support for replies and tap backs https://github.com/meshtastic/Meshtastic-device/issues/1035 --- src/mesh/generated/deviceonly.pb.h | 2 +- src/mesh/generated/mesh.pb.h | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/mesh/generated/deviceonly.pb.h b/src/mesh/generated/deviceonly.pb.h index 284aa68f7..34338b9c4 100644 --- a/src/mesh/generated/deviceonly.pb.h +++ b/src/mesh/generated/deviceonly.pb.h @@ -125,7 +125,7 @@ extern const pb_msgdesc_t ChannelFile_msg; /* Maximum encoded size of messages (where known) */ #define LegacyRadioConfig_size 4 #define LegacyRadioConfig_LegacyPreferences_size 2 -#define DeviceState_size 9949 +#define DeviceState_size 9967 #define ChannelFile_size 832 #ifdef __cplusplus diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index 7419ac023..27e7d53cd 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -234,6 +234,8 @@ typedef struct _MeshPacket { MeshPacket_Priority priority; int32_t rx_rssi; MeshPacket_Delayed delayed; + uint32_t reply_id; + bool is_tapback; } MeshPacket; typedef struct _NodeInfo { @@ -331,7 +333,7 @@ extern "C" { #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} -#define MeshPacket_init_default {0, 0, 0, 0, {Data_init_default}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN} +#define MeshPacket_init_default {0, 0, 0, 0, {Data_init_default}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN, 0, 0} #define NodeInfo_init_default {0, false, User_init_default, false, Position_init_default, 0, 0} #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, 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, 0, 0, 0}, 0, 0} #define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN} @@ -343,7 +345,7 @@ extern "C" { #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} -#define MeshPacket_init_zero {0, 0, 0, 0, {Data_init_zero}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN} +#define MeshPacket_init_zero {0, 0, 0, 0, {Data_init_zero}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN, 0, _MeshPacket_Delayed_MIN, 0, 0} #define NodeInfo_init_zero {0, false, User_init_zero, false, Position_init_zero, 0, 0} #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, 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, 0, 0, 0}, 0, 0} #define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN} @@ -429,6 +431,8 @@ extern "C" { #define MeshPacket_priority_tag 12 #define MeshPacket_rx_rssi_tag 13 #define MeshPacket_delayed_tag 15 +#define MeshPacket_reply_id_tag 16 +#define MeshPacket_is_tapback_tag 17 #define NodeInfo_num_tag 1 #define NodeInfo_user_tag 2 #define NodeInfo_position_tag 3 @@ -528,7 +532,9 @@ X(a, STATIC, SINGULAR, UINT32, hop_limit, 10) \ X(a, STATIC, SINGULAR, BOOL, want_ack, 11) \ X(a, STATIC, SINGULAR, UENUM, priority, 12) \ X(a, STATIC, SINGULAR, INT32, rx_rssi, 13) \ -X(a, STATIC, SINGULAR, UENUM, delayed, 15) +X(a, STATIC, SINGULAR, UENUM, delayed, 15) \ +X(a, STATIC, SINGULAR, FIXED32, reply_id, 16) \ +X(a, STATIC, SINGULAR, BOOL, is_tapback, 17) #define MeshPacket_CALLBACK NULL #define MeshPacket_DEFAULT NULL #define MeshPacket_payloadVariant_decoded_MSGTYPE Data @@ -638,12 +644,12 @@ extern const pb_msgdesc_t ToRadio_PeerInfo_msg; #define RouteDiscovery_size 40 #define Routing_size 42 #define Data_size 260 -#define MeshPacket_size 311 +#define MeshPacket_size 320 #define NodeInfo_size 270 #define MyNodeInfo_size 451 #define LogRecord_size 81 #define FromRadio_size 460 -#define ToRadio_size 314 +#define ToRadio_size 323 #define ToRadio_PeerInfo_size 8 #ifdef __cplusplus From 41dcfdd7cb4a3bac6808b6511fac9a529befe4a8 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Wed, 29 Dec 2021 11:20:36 -0800 Subject: [PATCH 17/17] Bump to 1.2.50 --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 13eff275e..7c9e94a60 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 1 minor = 2 -build = 49 +build = 50