Protobufs

This commit is contained in:
Ben Meadors
2024-08-10 07:25:05 -05:00
committed by Jonathan Bennett
parent 464f270b12
commit 8d1a34a4bf
9 changed files with 273 additions and 96 deletions

View File

@@ -76,98 +76,138 @@ typedef enum _meshtastic_TelemetrySensorType {
/* Key native device metrics such as battery level */
typedef struct _meshtastic_DeviceMetrics {
/* 0-100 (>100 means powered) */
bool has_battery_level;
uint32_t battery_level;
/* Voltage measured */
bool has_voltage;
float voltage;
/* Utilization for the current channel, including well formed TX, RX and malformed RX (aka noise). */
bool has_channel_utilization;
float channel_utilization;
/* Percent of airtime for transmission used within the last hour. */
bool has_air_util_tx;
float air_util_tx;
/* How long the device has been running since the last reboot (in seconds) */
bool has_uptime_seconds;
uint32_t uptime_seconds;
} meshtastic_DeviceMetrics;
/* Weather station or other environmental metrics */
typedef struct _meshtastic_EnvironmentMetrics {
/* Temperature measured */
bool has_temperature;
float temperature;
/* Relative humidity percent measured */
bool has_relative_humidity;
float relative_humidity;
/* Barometric pressure in hPA measured */
bool has_barometric_pressure;
float barometric_pressure;
/* Gas resistance in MOhm measured */
bool has_gas_resistance;
float gas_resistance;
/* Voltage measured (To be depreciated in favor of PowerMetrics in Meshtastic 3.x) */
bool has_voltage;
float voltage;
/* Current measured (To be depreciated in favor of PowerMetrics in Meshtastic 3.x) */
bool has_current;
float current;
/* relative scale IAQ value as measured by Bosch BME680 . value 0-500.
Belongs to Air Quality but is not particle but VOC measurement. Other VOC values can also be put in here. */
bool has_iaq;
uint16_t iaq;
/* RCWL9620 Doppler Radar Distance Sensor, used for water level detection. Float value in mm. */
bool has_distance;
float distance;
/* VEML7700 high accuracy ambient light(Lux) digital 16-bit resolution sensor. */
bool has_lux;
float lux;
/* VEML7700 high accuracy white light(irradiance) not calibrated digital 16-bit resolution sensor. */
bool has_white_lux;
float white_lux;
/* Infrared lux */
bool has_ir_lux;
float ir_lux;
/* Ultraviolet lux */
bool has_uv_lux;
float uv_lux;
/* Wind direction in degrees
0 degrees = North, 90 = East, etc... */
bool has_wind_direction;
uint16_t wind_direction;
/* Wind speed in m/s */
bool has_wind_speed;
float wind_speed;
/* Weight in KG */
bool has_weight;
float weight;
/* Wind gust in m/s */
bool has_wind_gust;
float wind_gust;
/* Wind lull in m/s */
bool has_wind_lull;
float wind_lull;
} meshtastic_EnvironmentMetrics;
/* Power Metrics (voltage / current / etc) */
typedef struct _meshtastic_PowerMetrics {
/* Voltage (Ch1) */
bool has_ch1_voltage;
float ch1_voltage;
/* Current (Ch1) */
bool has_ch1_current;
float ch1_current;
/* Voltage (Ch2) */
bool has_ch2_voltage;
float ch2_voltage;
/* Current (Ch2) */
bool has_ch2_current;
float ch2_current;
/* Voltage (Ch3) */
bool has_ch3_voltage;
float ch3_voltage;
/* Current (Ch3) */
bool has_ch3_current;
float ch3_current;
} meshtastic_PowerMetrics;
/* Air quality metrics */
typedef struct _meshtastic_AirQualityMetrics {
/* Concentration Units Standard PM1.0 */
bool has_pm10_standard;
uint32_t pm10_standard;
/* Concentration Units Standard PM2.5 */
bool has_pm25_standard;
uint32_t pm25_standard;
/* Concentration Units Standard PM10.0 */
bool has_pm100_standard;
uint32_t pm100_standard;
/* Concentration Units Environmental PM1.0 */
bool has_pm10_environmental;
uint32_t pm10_environmental;
/* Concentration Units Environmental PM2.5 */
bool has_pm25_environmental;
uint32_t pm25_environmental;
/* Concentration Units Environmental PM10.0 */
bool has_pm100_environmental;
uint32_t pm100_environmental;
/* 0.3um Particle Count */
bool has_particles_03um;
uint32_t particles_03um;
/* 0.5um Particle Count */
bool has_particles_05um;
uint32_t particles_05um;
/* 1.0um Particle Count */
bool has_particles_10um;
uint32_t particles_10um;
/* 2.5um Particle Count */
bool has_particles_25um;
uint32_t particles_25um;
/* 5.0um Particle Count */
bool has_particles_50um;
uint32_t particles_50um;
/* 10.0um Particle Count */
bool has_particles_100um;
uint32_t particles_100um;
} meshtastic_AirQualityMetrics;
@@ -214,16 +254,16 @@ extern "C" {
/* Initializer values for message structs */
#define meshtastic_DeviceMetrics_init_default {0, 0, 0, 0, 0}
#define meshtastic_EnvironmentMetrics_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
#define meshtastic_PowerMetrics_init_default {0, 0, 0, 0, 0, 0}
#define meshtastic_AirQualityMetrics_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
#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}
#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}
#define meshtastic_Telemetry_init_default {0, 0, {meshtastic_DeviceMetrics_init_default}}
#define meshtastic_Nau7802Config_init_default {0, 0}
#define meshtastic_DeviceMetrics_init_zero {0, 0, 0, 0, 0}
#define meshtastic_EnvironmentMetrics_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
#define meshtastic_PowerMetrics_init_zero {0, 0, 0, 0, 0, 0}
#define meshtastic_AirQualityMetrics_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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}
#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}
#define meshtastic_Telemetry_init_zero {0, 0, {meshtastic_DeviceMetrics_init_zero}}
#define meshtastic_Nau7802Config_init_zero {0, 0}
@@ -278,58 +318,58 @@ extern "C" {
/* Struct field encoding specification for nanopb */
#define meshtastic_DeviceMetrics_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, battery_level, 1) \
X(a, STATIC, SINGULAR, FLOAT, voltage, 2) \
X(a, STATIC, SINGULAR, FLOAT, channel_utilization, 3) \
X(a, STATIC, SINGULAR, FLOAT, air_util_tx, 4) \
X(a, STATIC, SINGULAR, UINT32, uptime_seconds, 5)
X(a, STATIC, OPTIONAL, UINT32, battery_level, 1) \
X(a, STATIC, OPTIONAL, FLOAT, voltage, 2) \
X(a, STATIC, OPTIONAL, FLOAT, channel_utilization, 3) \
X(a, STATIC, OPTIONAL, FLOAT, air_util_tx, 4) \
X(a, STATIC, OPTIONAL, UINT32, uptime_seconds, 5)
#define meshtastic_DeviceMetrics_CALLBACK NULL
#define meshtastic_DeviceMetrics_DEFAULT NULL
#define meshtastic_EnvironmentMetrics_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, FLOAT, temperature, 1) \
X(a, STATIC, SINGULAR, FLOAT, relative_humidity, 2) \
X(a, STATIC, SINGULAR, FLOAT, barometric_pressure, 3) \
X(a, STATIC, SINGULAR, FLOAT, gas_resistance, 4) \
X(a, STATIC, SINGULAR, FLOAT, voltage, 5) \
X(a, STATIC, SINGULAR, FLOAT, current, 6) \
X(a, STATIC, SINGULAR, UINT32, iaq, 7) \
X(a, STATIC, SINGULAR, FLOAT, distance, 8) \
X(a, STATIC, SINGULAR, FLOAT, lux, 9) \
X(a, STATIC, SINGULAR, FLOAT, white_lux, 10) \
X(a, STATIC, SINGULAR, FLOAT, ir_lux, 11) \
X(a, STATIC, SINGULAR, FLOAT, uv_lux, 12) \
X(a, STATIC, SINGULAR, UINT32, wind_direction, 13) \
X(a, STATIC, SINGULAR, FLOAT, wind_speed, 14) \
X(a, STATIC, SINGULAR, FLOAT, weight, 15) \
X(a, STATIC, SINGULAR, FLOAT, wind_gust, 16) \
X(a, STATIC, SINGULAR, FLOAT, wind_lull, 17)
X(a, STATIC, OPTIONAL, FLOAT, temperature, 1) \
X(a, STATIC, OPTIONAL, FLOAT, relative_humidity, 2) \
X(a, STATIC, OPTIONAL, FLOAT, barometric_pressure, 3) \
X(a, STATIC, OPTIONAL, FLOAT, gas_resistance, 4) \
X(a, STATIC, OPTIONAL, FLOAT, voltage, 5) \
X(a, STATIC, OPTIONAL, FLOAT, current, 6) \
X(a, STATIC, OPTIONAL, UINT32, iaq, 7) \
X(a, STATIC, OPTIONAL, FLOAT, distance, 8) \
X(a, STATIC, OPTIONAL, FLOAT, lux, 9) \
X(a, STATIC, OPTIONAL, FLOAT, white_lux, 10) \
X(a, STATIC, OPTIONAL, FLOAT, ir_lux, 11) \
X(a, STATIC, OPTIONAL, FLOAT, uv_lux, 12) \
X(a, STATIC, OPTIONAL, UINT32, wind_direction, 13) \
X(a, STATIC, OPTIONAL, FLOAT, wind_speed, 14) \
X(a, STATIC, OPTIONAL, FLOAT, weight, 15) \
X(a, STATIC, OPTIONAL, FLOAT, wind_gust, 16) \
X(a, STATIC, OPTIONAL, FLOAT, wind_lull, 17)
#define meshtastic_EnvironmentMetrics_CALLBACK NULL
#define meshtastic_EnvironmentMetrics_DEFAULT NULL
#define meshtastic_PowerMetrics_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, FLOAT, ch1_voltage, 1) \
X(a, STATIC, SINGULAR, FLOAT, ch1_current, 2) \
X(a, STATIC, SINGULAR, FLOAT, ch2_voltage, 3) \
X(a, STATIC, SINGULAR, FLOAT, ch2_current, 4) \
X(a, STATIC, SINGULAR, FLOAT, ch3_voltage, 5) \
X(a, STATIC, SINGULAR, FLOAT, ch3_current, 6)
X(a, STATIC, OPTIONAL, FLOAT, ch1_voltage, 1) \
X(a, STATIC, OPTIONAL, FLOAT, ch1_current, 2) \
X(a, STATIC, OPTIONAL, FLOAT, ch2_voltage, 3) \
X(a, STATIC, OPTIONAL, FLOAT, ch2_current, 4) \
X(a, STATIC, OPTIONAL, FLOAT, ch3_voltage, 5) \
X(a, STATIC, OPTIONAL, FLOAT, ch3_current, 6)
#define meshtastic_PowerMetrics_CALLBACK NULL
#define meshtastic_PowerMetrics_DEFAULT NULL
#define meshtastic_AirQualityMetrics_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, pm10_standard, 1) \
X(a, STATIC, SINGULAR, UINT32, pm25_standard, 2) \
X(a, STATIC, SINGULAR, UINT32, pm100_standard, 3) \
X(a, STATIC, SINGULAR, UINT32, pm10_environmental, 4) \
X(a, STATIC, SINGULAR, UINT32, pm25_environmental, 5) \
X(a, STATIC, SINGULAR, UINT32, pm100_environmental, 6) \
X(a, STATIC, SINGULAR, UINT32, particles_03um, 7) \
X(a, STATIC, SINGULAR, UINT32, particles_05um, 8) \
X(a, STATIC, SINGULAR, UINT32, particles_10um, 9) \
X(a, STATIC, SINGULAR, UINT32, particles_25um, 10) \
X(a, STATIC, SINGULAR, UINT32, particles_50um, 11) \
X(a, STATIC, SINGULAR, UINT32, particles_100um, 12)
X(a, STATIC, OPTIONAL, UINT32, pm10_standard, 1) \
X(a, STATIC, OPTIONAL, UINT32, pm25_standard, 2) \
X(a, STATIC, OPTIONAL, UINT32, pm100_standard, 3) \
X(a, STATIC, OPTIONAL, UINT32, pm10_environmental, 4) \
X(a, STATIC, OPTIONAL, UINT32, pm25_environmental, 5) \
X(a, STATIC, OPTIONAL, UINT32, pm100_environmental, 6) \
X(a, STATIC, OPTIONAL, UINT32, particles_03um, 7) \
X(a, STATIC, OPTIONAL, UINT32, particles_05um, 8) \
X(a, STATIC, OPTIONAL, UINT32, particles_10um, 9) \
X(a, STATIC, OPTIONAL, UINT32, particles_25um, 10) \
X(a, STATIC, OPTIONAL, UINT32, particles_50um, 11) \
X(a, STATIC, OPTIONAL, UINT32, particles_100um, 12)
#define meshtastic_AirQualityMetrics_CALLBACK NULL
#define meshtastic_AirQualityMetrics_DEFAULT NULL