From 9632e4c405069cfccf23b4cf274af14c169c6ea0 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Tue, 4 Jun 2024 07:04:25 -0500 Subject: [PATCH 1/3] Add missing excludes to environmental sensors (#4033) * DF Robot Lark weather station support * Missed it * I am a man of const char sorrow... * Strang * Use our fork * Add excludes --- src/modules/Telemetry/Sensor/AHT10.cpp | 12 +++++++++--- src/modules/Telemetry/Sensor/AHT10.h | 6 ++++++ src/modules/Telemetry/Sensor/TSL2591Sensor.cpp | 13 +++++++++---- src/modules/Telemetry/Sensor/TSL2591Sensor.h | 7 ++++++- src/modules/Telemetry/Sensor/VEML7700Sensor.cpp | 11 ++++++++--- src/modules/Telemetry/Sensor/VEML7700Sensor.h | 7 ++++++- 6 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/modules/Telemetry/Sensor/AHT10.cpp b/src/modules/Telemetry/Sensor/AHT10.cpp index 985515bb6..a5212b39b 100644 --- a/src/modules/Telemetry/Sensor/AHT10.cpp +++ b/src/modules/Telemetry/Sensor/AHT10.cpp @@ -1,7 +1,11 @@ -#include "AHT10.h" -#include "../mesh/generated/meshtastic/telemetry.pb.h" -#include "TelemetrySensor.h" #include "configuration.h" + +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + +#include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "AHT10.h" +#include "TelemetrySensor.h" + #include #include @@ -33,3 +37,5 @@ bool AHT10Sensor::getMetrics(meshtastic_Telemetry *measurement) return true; } + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/AHT10.h b/src/modules/Telemetry/Sensor/AHT10.h index b2b7b47f3..d9a133402 100644 --- a/src/modules/Telemetry/Sensor/AHT10.h +++ b/src/modules/Telemetry/Sensor/AHT10.h @@ -1,3 +1,7 @@ +#include "configuration.h" + +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include @@ -15,3 +19,5 @@ class AHT10Sensor : public TelemetrySensor virtual int32_t runOnce() override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override; }; + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/TSL2591Sensor.cpp b/src/modules/Telemetry/Sensor/TSL2591Sensor.cpp index 0a3f5d685..d20e48dce 100644 --- a/src/modules/Telemetry/Sensor/TSL2591Sensor.cpp +++ b/src/modules/Telemetry/Sensor/TSL2591Sensor.cpp @@ -1,7 +1,10 @@ -#include "TSL2591Sensor.h" -#include "../mesh/generated/meshtastic/telemetry.pb.h" -#include "TelemetrySensor.h" #include "configuration.h" + +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + +#include "../mesh/generated/meshtastic/telemetry.pb.h" +#include "TSL2591Sensor.h" +#include "TelemetrySensor.h" #include #include @@ -35,4 +38,6 @@ bool TSL2591Sensor::getMetrics(meshtastic_Telemetry *measurement) LOG_INFO("Lux: %f\n", measurement->variant.environment_metrics.lux); return true; -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/TSL2591Sensor.h b/src/modules/Telemetry/Sensor/TSL2591Sensor.h index a24d53975..27bebdfe5 100644 --- a/src/modules/Telemetry/Sensor/TSL2591Sensor.h +++ b/src/modules/Telemetry/Sensor/TSL2591Sensor.h @@ -1,3 +1,7 @@ +#include "configuration.h" + +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include @@ -14,4 +18,5 @@ class TSL2591Sensor : public TelemetrySensor TSL2591Sensor(); virtual int32_t runOnce() override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override; -}; \ No newline at end of file +}; +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp b/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp index 1abe8339f..cbeaf4c2e 100644 --- a/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp +++ b/src/modules/Telemetry/Sensor/VEML7700Sensor.cpp @@ -1,7 +1,11 @@ -#include "VEML7700Sensor.h" +#include "configuration.h" + +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" -#include "configuration.h" +#include "VEML7700Sensor.h" + #include #include @@ -57,4 +61,5 @@ bool VEML7700Sensor::getMetrics(meshtastic_Telemetry *measurement) measurement->variant.environment_metrics.lux); return true; -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/modules/Telemetry/Sensor/VEML7700Sensor.h b/src/modules/Telemetry/Sensor/VEML7700Sensor.h index 9c7a584d9..97e57334c 100644 --- a/src/modules/Telemetry/Sensor/VEML7700Sensor.h +++ b/src/modules/Telemetry/Sensor/VEML7700Sensor.h @@ -1,3 +1,7 @@ +#include "configuration.h" + +#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR + #include "../mesh/generated/meshtastic/telemetry.pb.h" #include "TelemetrySensor.h" #include @@ -19,4 +23,5 @@ class VEML7700Sensor : public TelemetrySensor VEML7700Sensor(); virtual int32_t runOnce() override; virtual bool getMetrics(meshtastic_Telemetry *measurement) override; -}; \ No newline at end of file +}; +#endif \ No newline at end of file From 181f03cb9538fea30cf00ff155dc5298881190f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Tue, 4 Jun 2024 15:14:27 +0200 Subject: [PATCH 2/3] tryfix random values (#4034) --- src/modules/Telemetry/AirQualityTelemetry.cpp | 2 +- src/modules/Telemetry/DeviceTelemetry.cpp | 2 +- src/modules/Telemetry/EnvironmentTelemetry.cpp | 4 ++-- src/modules/Telemetry/PowerTelemetry.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/Telemetry/AirQualityTelemetry.cpp b/src/modules/Telemetry/AirQualityTelemetry.cpp index e4f31ff9f..4f5fbcd13 100644 --- a/src/modules/Telemetry/AirQualityTelemetry.cpp +++ b/src/modules/Telemetry/AirQualityTelemetry.cpp @@ -92,7 +92,7 @@ bool AirQualityTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) return false; } - meshtastic_Telemetry m; + meshtastic_Telemetry m = meshtastic_Telemetry_init_zero; m.time = getTime(); m.which_variant = meshtastic_Telemetry_air_quality_metrics_tag; m.variant.air_quality_metrics.pm10_standard = data.pm10_standard; diff --git a/src/modules/Telemetry/DeviceTelemetry.cpp b/src/modules/Telemetry/DeviceTelemetry.cpp index 002ce62a9..b64e8d113 100644 --- a/src/modules/Telemetry/DeviceTelemetry.cpp +++ b/src/modules/Telemetry/DeviceTelemetry.cpp @@ -64,7 +64,7 @@ meshtastic_MeshPacket *DeviceTelemetryModule::allocReply() meshtastic_Telemetry DeviceTelemetryModule::getDeviceTelemetry() { - meshtastic_Telemetry t; + meshtastic_Telemetry t = meshtastic_Telemetry_init_zero; t.time = getTime(); t.which_variant = meshtastic_Telemetry_device_metrics_tag; diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index 8972a8e3f..46b8a1ad8 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -261,7 +261,7 @@ bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPac bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) { - meshtastic_Telemetry m; + meshtastic_Telemetry m = meshtastic_Telemetry_init_zero; bool valid = true; bool hasSensor = false; m.time = getTime(); @@ -337,7 +337,7 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) hasSensor = true; } else { // prefer bmp280 temp if both sensors are present, fetch only humidity - meshtastic_Telemetry m_ahtx; + meshtastic_Telemetry m_ahtx = meshtastic_Telemetry_init_zero; LOG_INFO("AHTX0+BMP280 module detected: using temp from BMP280 and humy from AHTX0\n"); aht10Sensor.getMetrics(&m_ahtx); m.variant.environment_metrics.relative_humidity = m_ahtx.variant.environment_metrics.relative_humidity; diff --git a/src/modules/Telemetry/PowerTelemetry.cpp b/src/modules/Telemetry/PowerTelemetry.cpp index e61a4e629..826de8a4a 100644 --- a/src/modules/Telemetry/PowerTelemetry.cpp +++ b/src/modules/Telemetry/PowerTelemetry.cpp @@ -165,7 +165,7 @@ bool PowerTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &m bool PowerTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) { - meshtastic_Telemetry m; + meshtastic_Telemetry m = meshtastic_Telemetry_init_zero; bool valid = false; m.time = getTime(); m.which_variant = meshtastic_Telemetry_power_metrics_tag; From 67b67a481f2756568feaa876006103fb8ba4dede Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 08:34:38 -0500 Subject: [PATCH 3/3] [create-pull-request] automated change (#4035) --- protobufs | 2 +- src/mesh/generated/meshtastic/mesh.pb.cpp | 9 +++ src/mesh/generated/meshtastic/mesh.pb.h | 83 +++++++++++++++++++++++ 3 files changed, 93 insertions(+), 1 deletion(-) diff --git a/protobufs b/protobufs index bfbf4a65e..a641c5ce4 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit bfbf4a65e220581f45c5ed949c659953ac4d080f +Subproject commit a641c5ce4fca158d18ca3cffc92ac7a10f9b6a04 diff --git a/src/mesh/generated/meshtastic/mesh.pb.cpp b/src/mesh/generated/meshtastic/mesh.pb.cpp index 4907affc6..46d59d609 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.cpp +++ b/src/mesh/generated/meshtastic/mesh.pb.cpp @@ -66,6 +66,15 @@ PB_BIND(meshtastic_Heartbeat, meshtastic_Heartbeat, AUTO) PB_BIND(meshtastic_NodeRemoteHardwarePin, meshtastic_NodeRemoteHardwarePin, AUTO) +PB_BIND(meshtastic_ChunkedPayload, meshtastic_ChunkedPayload, AUTO) + + +PB_BIND(meshtastic_resend_chunks, meshtastic_resend_chunks, AUTO) + + +PB_BIND(meshtastic_ChunkedPayloadResponse, meshtastic_ChunkedPayloadResponse, AUTO) + + diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index 7b544d714..ad97cb80f 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -65,6 +65,8 @@ typedef enum _meshtastic_HardwareModel { meshtastic_HardwareModel_LORA_TYPE = 19, /* wiphone https://www.wiphone.io/ */ meshtastic_HardwareModel_WIPHONE = 20, + /* WIO Tracker WM1110 family from Seeed Studio. Includes wio-1110-tracker and wio-1110-sdk */ + meshtastic_HardwareModel_WIO_WM1110 = 21, /* B&Q Consulting Station Edition G1: https://uniteng.com/wiki/doku.php?id=meshtastic:station */ meshtastic_HardwareModel_STATION_G1 = 25, /* RAK11310 (RP2040 + SX1262) */ @@ -853,6 +855,38 @@ typedef struct _meshtastic_NodeRemoteHardwarePin { meshtastic_RemoteHardwarePin pin; } meshtastic_NodeRemoteHardwarePin; +typedef PB_BYTES_ARRAY_T(228) meshtastic_ChunkedPayload_payload_chunk_t; +typedef struct _meshtastic_ChunkedPayload { + /* The ID of the entire payload */ + uint32_t payload_id; + /* The total number of chunks in the payload */ + uint16_t chunk_count; + /* The current chunk index in the total */ + uint16_t chunk_index; + /* The binary data of the current chunk */ + meshtastic_ChunkedPayload_payload_chunk_t payload_chunk; +} meshtastic_ChunkedPayload; + +/* Wrapper message for broken repeated oneof support */ +typedef struct _meshtastic_resend_chunks { + pb_callback_t chunks; +} meshtastic_resend_chunks; + +/* Responses to a ChunkedPayload request */ +typedef struct _meshtastic_ChunkedPayloadResponse { + /* The ID of the entire payload */ + uint32_t payload_id; + pb_size_t which_payload_variant; + union { + /* Request to transfer chunked payload */ + bool request_transfer; + /* Accept the transfer chunked payload */ + bool accept_transfer; + /* Request missing indexes in the chunked payload */ + meshtastic_resend_chunks resend_chunks; + } payload_variant; +} meshtastic_ChunkedPayloadResponse; + #ifdef __cplusplus extern "C" { @@ -928,6 +962,9 @@ extern "C" { + + + /* Initializer values for message structs */ #define meshtastic_Position_init_default {0, 0, 0, 0, _meshtastic_Position_LocSource_MIN, _meshtastic_Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_User_init_default {"", "", "", {0}, _meshtastic_HardwareModel_MIN, 0, _meshtastic_Config_DeviceConfig_Role_MIN} @@ -949,6 +986,9 @@ extern "C" { #define meshtastic_DeviceMetadata_init_default {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN, 0} #define meshtastic_Heartbeat_init_default {0} #define meshtastic_NodeRemoteHardwarePin_init_default {0, false, meshtastic_RemoteHardwarePin_init_default} +#define meshtastic_ChunkedPayload_init_default {0, 0, 0, {0, {0}}} +#define meshtastic_resend_chunks_init_default {{{NULL}, NULL}} +#define meshtastic_ChunkedPayloadResponse_init_default {0, 0, {0}} #define meshtastic_Position_init_zero {0, 0, 0, 0, _meshtastic_Position_LocSource_MIN, _meshtastic_Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_User_init_zero {"", "", "", {0}, _meshtastic_HardwareModel_MIN, 0, _meshtastic_Config_DeviceConfig_Role_MIN} #define meshtastic_RouteDiscovery_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}} @@ -969,6 +1009,9 @@ extern "C" { #define meshtastic_DeviceMetadata_init_zero {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN, 0} #define meshtastic_Heartbeat_init_zero {0} #define meshtastic_NodeRemoteHardwarePin_init_zero {0, false, meshtastic_RemoteHardwarePin_init_zero} +#define meshtastic_ChunkedPayload_init_zero {0, 0, 0, {0, {0}}} +#define meshtastic_resend_chunks_init_zero {{{NULL}, NULL}} +#define meshtastic_ChunkedPayloadResponse_init_zero {0, 0, {0}} /* Field tags (for use in manual encoding/decoding) */ #define meshtastic_Position_latitude_i_tag 1 @@ -1103,6 +1146,15 @@ extern "C" { #define meshtastic_ToRadio_heartbeat_tag 7 #define meshtastic_NodeRemoteHardwarePin_node_num_tag 1 #define meshtastic_NodeRemoteHardwarePin_pin_tag 2 +#define meshtastic_ChunkedPayload_payload_id_tag 1 +#define meshtastic_ChunkedPayload_chunk_count_tag 2 +#define meshtastic_ChunkedPayload_chunk_index_tag 3 +#define meshtastic_ChunkedPayload_payload_chunk_tag 4 +#define meshtastic_resend_chunks_chunks_tag 1 +#define meshtastic_ChunkedPayloadResponse_payload_id_tag 1 +#define meshtastic_ChunkedPayloadResponse_request_transfer_tag 2 +#define meshtastic_ChunkedPayloadResponse_accept_transfer_tag 3 +#define meshtastic_ChunkedPayloadResponse_resend_chunks_tag 4 /* Struct field encoding specification for nanopb */ #define meshtastic_Position_FIELDLIST(X, a) \ @@ -1341,6 +1393,28 @@ X(a, STATIC, OPTIONAL, MESSAGE, pin, 2) #define meshtastic_NodeRemoteHardwarePin_DEFAULT NULL #define meshtastic_NodeRemoteHardwarePin_pin_MSGTYPE meshtastic_RemoteHardwarePin +#define meshtastic_ChunkedPayload_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, payload_id, 1) \ +X(a, STATIC, SINGULAR, UINT32, chunk_count, 2) \ +X(a, STATIC, SINGULAR, UINT32, chunk_index, 3) \ +X(a, STATIC, SINGULAR, BYTES, payload_chunk, 4) +#define meshtastic_ChunkedPayload_CALLBACK NULL +#define meshtastic_ChunkedPayload_DEFAULT NULL + +#define meshtastic_resend_chunks_FIELDLIST(X, a) \ +X(a, CALLBACK, REPEATED, UINT32, chunks, 1) +#define meshtastic_resend_chunks_CALLBACK pb_default_field_callback +#define meshtastic_resend_chunks_DEFAULT NULL + +#define meshtastic_ChunkedPayloadResponse_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, payload_id, 1) \ +X(a, STATIC, ONEOF, BOOL, (payload_variant,request_transfer,payload_variant.request_transfer), 2) \ +X(a, STATIC, ONEOF, BOOL, (payload_variant,accept_transfer,payload_variant.accept_transfer), 3) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,resend_chunks,payload_variant.resend_chunks), 4) +#define meshtastic_ChunkedPayloadResponse_CALLBACK NULL +#define meshtastic_ChunkedPayloadResponse_DEFAULT NULL +#define meshtastic_ChunkedPayloadResponse_payload_variant_resend_chunks_MSGTYPE meshtastic_resend_chunks + extern const pb_msgdesc_t meshtastic_Position_msg; extern const pb_msgdesc_t meshtastic_User_msg; extern const pb_msgdesc_t meshtastic_RouteDiscovery_msg; @@ -1361,6 +1435,9 @@ extern const pb_msgdesc_t meshtastic_Neighbor_msg; extern const pb_msgdesc_t meshtastic_DeviceMetadata_msg; extern const pb_msgdesc_t meshtastic_Heartbeat_msg; extern const pb_msgdesc_t meshtastic_NodeRemoteHardwarePin_msg; +extern const pb_msgdesc_t meshtastic_ChunkedPayload_msg; +extern const pb_msgdesc_t meshtastic_resend_chunks_msg; +extern const pb_msgdesc_t meshtastic_ChunkedPayloadResponse_msg; /* Defines for backwards compatibility with code written before nanopb-0.4.0 */ #define meshtastic_Position_fields &meshtastic_Position_msg @@ -1383,9 +1460,15 @@ extern const pb_msgdesc_t meshtastic_NodeRemoteHardwarePin_msg; #define meshtastic_DeviceMetadata_fields &meshtastic_DeviceMetadata_msg #define meshtastic_Heartbeat_fields &meshtastic_Heartbeat_msg #define meshtastic_NodeRemoteHardwarePin_fields &meshtastic_NodeRemoteHardwarePin_msg +#define meshtastic_ChunkedPayload_fields &meshtastic_ChunkedPayload_msg +#define meshtastic_resend_chunks_fields &meshtastic_resend_chunks_msg +#define meshtastic_ChunkedPayloadResponse_fields &meshtastic_ChunkedPayloadResponse_msg /* Maximum encoded size of messages (where known) */ +/* meshtastic_resend_chunks_size depends on runtime parameters */ +/* meshtastic_ChunkedPayloadResponse_size depends on runtime parameters */ #define MESHTASTIC_MESHTASTIC_MESH_PB_H_MAX_SIZE meshtastic_FromRadio_size +#define meshtastic_ChunkedPayload_size 245 #define meshtastic_Compressed_size 243 #define meshtastic_Data_size 270 #define meshtastic_DeviceMetadata_size 46