diff --git a/platformio.ini b/platformio.ini index f41726503..310134c30 100644 --- a/platformio.ini +++ b/platformio.ini @@ -60,7 +60,7 @@ lib_deps = mathertel/OneButton@2.6.1 https://github.com/meshtastic/arduino-fsm.git#7db3702bf0cfe97b783d6c72595e3f38e0b19159 https://github.com/meshtastic/TinyGPSPlus.git#71a82db35f3b973440044c476d4bcdc673b104f4 - https://github.com/meshtastic/ArduinoThread.git#1ae8778c85d0a2a729f989e0b1e7d7c4dc84eef0 + https://github.com/meshtastic/ArduinoThread.git#7c3ee9e1951551b949763b1f5280f8db1fa4068d nanopb/Nanopb@0.4.91 erriez/ErriezCRC32@1.0.1 @@ -94,7 +94,7 @@ lib_deps = [device-ui_base] lib_deps = - https://github.com/meshtastic/device-ui.git#8c3183e177a1d6452ce12b4f328bd3357bf7e21b + https://github.com/meshtastic/device-ui.git#d7b18e98704f988fcda9e5fa7404e677b3d11f8c ; Common libs for environmental measurements in telemetry module ; (not included in native / portduino) diff --git a/protobufs b/protobufs index c261bd71a..035a8017b 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit c261bd71aaf416f3bcef5dbc774d06b797fc58c6 +Subproject commit 035a8017b87379f17624f7bba9b6a5b127bc026c diff --git a/src/main.cpp b/src/main.cpp index 607dfc5ad..2e275964b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -643,7 +643,7 @@ void setup() scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::DFROBOT_RAIN, meshtastic_TelemetrySensorType_DFROBOT_RAIN); scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::LTR390UV, meshtastic_TelemetrySensorType_LTR390UV); scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::DPS310, meshtastic_TelemetrySensorType_DPS310); - // scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::RAK12035, meshtastic_TelemetrySensorType_RAK12035); + scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::RAK12035, meshtastic_TelemetrySensorType_RAK12035); i2cScanner.reset(); #endif diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 0ef21d4ca..3bb1f2776 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -88,8 +88,16 @@ int MeshService::handleFromRadio(const meshtastic_MeshPacket *mp) } else if (mp->which_payload_variant == meshtastic_MeshPacket_decoded_tag && !nodeDB->getMeshNode(mp->from)->has_user && nodeInfoModule && !isPreferredRebroadcaster && !nodeDB->isFull()) { if (airTime->isTxAllowedChannelUtil(true)) { - LOG_INFO("Heard new node on ch. %d, send NodeInfo and ask for response", mp->channel); - nodeInfoModule->sendOurNodeInfo(mp->from, true, mp->channel); + // Hops used by the request. If somebody in between running modified firmware modified it, ignore it + auto hopStart = mp->hop_start; + auto hopLimit = mp->hop_limit; + uint8_t hopsUsed = hopStart < hopLimit ? config.lora.hop_limit : hopStart - hopLimit; + if (hopsUsed > config.lora.hop_limit + 2) { + LOG_DEBUG("Skip send NodeInfo: %d hops away is too far away", hopsUsed); + } else { + LOG_INFO("Heard new node on ch. %d, send NodeInfo and ask for response", mp->channel); + nodeInfoModule->sendOurNodeInfo(mp->from, true, mp->channel); + } } else { LOG_DEBUG("Skip sending NodeInfo > 25%% ch. util"); } diff --git a/src/mesh/generated/meshtastic/portnums.pb.h b/src/mesh/generated/meshtastic/portnums.pb.h index d7dc47785..4e7c43e58 100644 --- a/src/mesh/generated/meshtastic/portnums.pb.h +++ b/src/mesh/generated/meshtastic/portnums.pb.h @@ -128,6 +128,9 @@ typedef enum _meshtastic_PortNum { meshtastic_PortNum_MAP_REPORT_APP = 73, /* PowerStress based monitoring support (for automated power consumption testing) */ meshtastic_PortNum_POWERSTRESS_APP = 74, + /* Reticulum Network Stack Tunnel App + ENCODING: Fragmented RNS Packet. Handled by Meshtastic RNS interface */ + meshtastic_PortNum_RETICULUM_TUNNEL_APP = 76, /* Private applications should use portnums >= 256. To simplify initial development and testing you can use "PRIVATE_APP" in your code without needing to rebuild protobuf files (via [regen-protos.sh](https://github.com/meshtastic/firmware/blob/master/bin/regen-protos.sh)) */ diff --git a/src/mesh/generated/meshtastic/telemetry.pb.h b/src/mesh/generated/meshtastic/telemetry.pb.h index aa39a1ce4..69cdd33fe 100644 --- a/src/mesh/generated/meshtastic/telemetry.pb.h +++ b/src/mesh/generated/meshtastic/telemetry.pb.h @@ -85,7 +85,9 @@ typedef enum _meshtastic_TelemetrySensorType { /* DFRobot Gravity tipping bucket rain gauge */ meshtastic_TelemetrySensorType_DFROBOT_RAIN = 35, /* Infineon DPS310 High accuracy pressure and temperature */ - meshtastic_TelemetrySensorType_DPS310 = 36 + meshtastic_TelemetrySensorType_DPS310 = 36, + /* RAKWireless RAK12035 Soil Moisture Sensor Module */ + meshtastic_TelemetrySensorType_RAK12035 = 37 } meshtastic_TelemetrySensorType; /* Struct definitions */ @@ -172,6 +174,12 @@ typedef struct _meshtastic_EnvironmentMetrics { /* Rainfall in the last 24 hours in mm */ bool has_rainfall_24h; float rainfall_24h; + /* Soil moisture measured (% 1-100) */ + bool has_soil_moisture; + uint8_t soil_moisture; + /* Soil temperature measured (*C) */ + bool has_soil_temperature; + float soil_temperature; } meshtastic_EnvironmentMetrics; /* Power Metrics (voltage / current / etc) */ @@ -316,8 +324,8 @@ extern "C" { /* Helper constants for enums */ #define _meshtastic_TelemetrySensorType_MIN meshtastic_TelemetrySensorType_SENSOR_UNSET -#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_DPS310 -#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_DPS310+1)) +#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_RAK12035 +#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_RAK12035+1)) @@ -330,7 +338,7 @@ extern "C" { /* Initializer values for message structs */ #define meshtastic_DeviceMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0} -#define meshtastic_EnvironmentMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} +#define meshtastic_EnvironmentMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_PowerMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_AirQualityMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_LocalStats_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} @@ -338,7 +346,7 @@ extern "C" { #define meshtastic_Telemetry_init_default {0, 0, {meshtastic_DeviceMetrics_init_default}} #define meshtastic_Nau7802Config_init_default {0, 0} #define meshtastic_DeviceMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0} -#define meshtastic_EnvironmentMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} +#define meshtastic_EnvironmentMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_PowerMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_AirQualityMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_LocalStats_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} @@ -372,6 +380,8 @@ extern "C" { #define meshtastic_EnvironmentMetrics_radiation_tag 18 #define meshtastic_EnvironmentMetrics_rainfall_1h_tag 19 #define meshtastic_EnvironmentMetrics_rainfall_24h_tag 20 +#define meshtastic_EnvironmentMetrics_soil_moisture_tag 21 +#define meshtastic_EnvironmentMetrics_soil_temperature_tag 22 #define meshtastic_PowerMetrics_ch1_voltage_tag 1 #define meshtastic_PowerMetrics_ch1_current_tag 2 #define meshtastic_PowerMetrics_ch2_voltage_tag 3 @@ -445,7 +455,9 @@ X(a, STATIC, OPTIONAL, FLOAT, wind_gust, 16) \ X(a, STATIC, OPTIONAL, FLOAT, wind_lull, 17) \ X(a, STATIC, OPTIONAL, FLOAT, radiation, 18) \ X(a, STATIC, OPTIONAL, FLOAT, rainfall_1h, 19) \ -X(a, STATIC, OPTIONAL, FLOAT, rainfall_24h, 20) +X(a, STATIC, OPTIONAL, FLOAT, rainfall_24h, 20) \ +X(a, STATIC, OPTIONAL, UINT32, soil_moisture, 21) \ +X(a, STATIC, OPTIONAL, FLOAT, soil_temperature, 22) #define meshtastic_EnvironmentMetrics_CALLBACK NULL #define meshtastic_EnvironmentMetrics_DEFAULT NULL @@ -544,12 +556,12 @@ extern const pb_msgdesc_t meshtastic_Nau7802Config_msg; #define MESHTASTIC_MESHTASTIC_TELEMETRY_PB_H_MAX_SIZE meshtastic_Telemetry_size #define meshtastic_AirQualityMetrics_size 78 #define meshtastic_DeviceMetrics_size 27 -#define meshtastic_EnvironmentMetrics_size 103 +#define meshtastic_EnvironmentMetrics_size 113 #define meshtastic_HealthMetrics_size 11 #define meshtastic_LocalStats_size 60 #define meshtastic_Nau7802Config_size 16 #define meshtastic_PowerMetrics_size 30 -#define meshtastic_Telemetry_size 110 +#define meshtastic_Telemetry_size 120 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index 6c9be53b4..adbe65c67 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -570,8 +570,8 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) LOG_INFO("Send: radiation=%fµR/h", m.variant.environment_metrics.radiation); - // LOG_INFO("Send: soil_temperature=%f, soil_moisture=%u", - // m.variant.environment_metrics.soil_temperature, m.variant.environment_metrics.soil_moisture); + LOG_INFO("Send: soil_temperature=%f, soil_moisture=%u", m.variant.environment_metrics.soil_temperature, + m.variant.environment_metrics.soil_moisture); sensor_read_error_count = 0; @@ -742,4 +742,4 @@ AdminMessageHandleResult EnvironmentTelemetryModule::handleAdminMessageForModule return result; } -#endif \ No newline at end of file +#endif diff --git a/variants/CDEBYTE_E77-MBL/platformio.ini b/variants/CDEBYTE_E77-MBL/platformio.ini new file mode 100644 index 000000000..a8d90f676 --- /dev/null +++ b/variants/CDEBYTE_E77-MBL/platformio.ini @@ -0,0 +1,41 @@ +[env:CDEBYTE_E77-MBL] +extends = stm32_base +; `ebyte_e77_dev` was added in this commit. Remove when a new release is used in the base. +platform = https://github.com/platformio/platform-ststm32.git#3208828db447f4373cd303b7f7393c8fc0dae623 +board = ebyte_e77_dev +board_level = extra +build_flags = + ${stm32_base.build_flags} + -Ivariants/CDEBYTE_E77-MBL + -DSERIAL_UART_INSTANCE=1 + -DPIN_SERIAL_RX=PA3 + -DPIN_SERIAL_TX=PA2 + -DHAL_DAC_MODULE_ONLY + -DHAL_ADC_MODULE_DISABLED + -DHAL_COMP_MODULE_DISABLED + -DHAL_CRC_MODULE_DISABLED + -DHAL_CRYP_MODULE_DISABLED + -DHAL_GTZC_MODULE_DISABLED + -DHAL_HSEM_MODULE_DISABLED + -DHAL_I2C_MODULE_DISABLED + -DHAL_I2S_MODULE_DISABLED + -DHAL_IPCC_MODULE_DISABLED + -DHAL_IRDA_MODULE_DISABLED + -DHAL_IWDG_MODULE_DISABLED + -DHAL_LPTIM_MODULE_DISABLED + -DHAL_PKA_MODULE_DISABLED + -DHAL_RNG_MODULE_DISABLED + -DHAL_RTC_MODULE_DISABLED + -DHAL_SMARTCARD_MODULE_DISABLED + -DHAL_SMBUS_MODULE_DISABLED + -DHAL_TIM_MODULE_DISABLED + -DHAL_WWDG_MODULE_DISABLED + -DHAL_EXTI_MODULE_DISABLED + -DHAL_SAI_MODULE_DISABLED + -DHAL_ICACHE_MODULE_DISABLED + -DRADIOLIB_EXCLUDE_SX128X=1 + -DRADIOLIB_EXCLUDE_SX127X=1 + -DRADIOLIB_EXCLUDE_LR11X0=1 +; -D PIO_FRAMEWORK_ARDUINO_NANOLIB_FLOAT_PRINTF + +upload_port = stlink \ No newline at end of file diff --git a/variants/CDEBYTE_E77-MBL/variant.h b/variants/CDEBYTE_E77-MBL/variant.h new file mode 100644 index 000000000..7331dcedc --- /dev/null +++ b/variants/CDEBYTE_E77-MBL/variant.h @@ -0,0 +1,23 @@ +/* +EByte E77-MBL series +https://www.cdebyte.com/products/E77-900MBL-01 +https://www.cdebyte.com/products/E77-400MBL-01 +https://github.com/olliw42/mLRS-docu/blob/master/docs/EBYTE_E77_MBL.md +*/ + +/* +This variant is a work in progress. +Do not expect a working Meshtastic device with this target. +*/ + +#ifndef _VARIANT_EBYTE_E77_ +#define _VARIANT_EBYTE_E77_ + +#define USE_STM32WLx +#define MAX_NUM_NODES 10 + +#define LED_PIN PB4 // LED1 +// #define LED_PIN PB3 // LED2 +#define LED_STATE_ON 1 + +#endif