From 2b87e57cdd98a05bc3b52ae413f3710859e7f098 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Tue, 6 Aug 2024 17:17:06 -0700 Subject: [PATCH 01/15] dos2unix telemetry.proto --- meshtastic/telemetry.proto | 826 ++++++++++++++++++------------------- 1 file changed, 413 insertions(+), 413 deletions(-) diff --git a/meshtastic/telemetry.proto b/meshtastic/telemetry.proto index 8ffbeb2e..ffea320e 100644 --- a/meshtastic/telemetry.proto +++ b/meshtastic/telemetry.proto @@ -1,413 +1,413 @@ -syntax = "proto3"; - -package meshtastic; - -option csharp_namespace = "Meshtastic.Protobufs"; -option go_package = "github.com/meshtastic/go/generated"; -option java_outer_classname = "TelemetryProtos"; -option java_package = "com.geeksville.mesh"; -option swift_prefix = ""; - -/* - * Key native device metrics such as battery level - */ -message DeviceMetrics { - /* - * 0-100 (>100 means powered) - */ - uint32 battery_level = 1; - - /* - * Voltage measured - */ - float voltage = 2; - - /* - * Utilization for the current channel, including well formed TX, RX and malformed RX (aka noise). - */ - float channel_utilization = 3; - - /* - * Percent of airtime for transmission used within the last hour. - */ - float air_util_tx = 4; - - /* - * How long the device has been running since the last reboot (in seconds) - */ - uint32 uptime_seconds = 5; -} - -/* - * Weather station or other environmental metrics - */ -message EnvironmentMetrics { - /* - * Temperature measured - */ - float temperature = 1; - - /* - * Relative humidity percent measured - */ - float relative_humidity = 2; - - /* - * Barometric pressure in hPA measured - */ - float barometric_pressure = 3; - - /* - * Gas resistance in MOhm measured - */ - float gas_resistance = 4; - - /* - * Voltage measured (To be depreciated in favor of PowerMetrics in Meshtastic 3.x) - */ - float voltage = 5; - - /* - * Current measured (To be depreciated in favor of PowerMetrics in Meshtastic 3.x) - */ - float current = 6; - - /* - * 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. - */ - uint32 iaq = 7; - - /* - * RCWL9620 Doppler Radar Distance Sensor, used for water level detection. Float value in mm. - */ - float distance = 8; - - /* - * VEML7700 high accuracy ambient light(Lux) digital 16-bit resolution sensor. - */ - float lux = 9; - - /* - * VEML7700 high accuracy white light(irradiance) not calibrated digital 16-bit resolution sensor. - */ - float white_lux = 10; - - /* - * Infrared lux - */ - float ir_lux = 11; - - /* - * Ultraviolet lux - */ - float uv_lux = 12; - - /* - * Wind direction in degrees - * 0 degrees = North, 90 = East, etc... - */ - uint32 wind_direction = 13; - - /* - * Wind speed in m/s - */ - float wind_speed = 14; - - /* - * Weight in KG - */ - float weight = 15; - - /* - * Wind gust in m/s - */ - float wind_gust = 16; - - /* - * Wind lull in m/s - */ - float wind_lull = 17; -} - -/* - * Power Metrics (voltage / current / etc) - */ -message PowerMetrics { - /* - * Voltage (Ch1) - */ - float ch1_voltage = 1; - - /* - * Current (Ch1) - */ - float ch1_current = 2; - - /* - * Voltage (Ch2) - */ - float ch2_voltage = 3; - - /* - * Current (Ch2) - */ - float ch2_current = 4; - - /* - * Voltage (Ch3) - */ - float ch3_voltage = 5; - - /* - * Current (Ch3) - */ - float ch3_current = 6; -} - -/* - * Air quality metrics - */ -message AirQualityMetrics { - /* - * Concentration Units Standard PM1.0 - */ - uint32 pm10_standard = 1; - - /* - * Concentration Units Standard PM2.5 - */ - uint32 pm25_standard = 2; - - /* - * Concentration Units Standard PM10.0 - */ - uint32 pm100_standard = 3; - - /* - * Concentration Units Environmental PM1.0 - */ - uint32 pm10_environmental = 4; - - /* - * Concentration Units Environmental PM2.5 - */ - uint32 pm25_environmental = 5; - - /* - * Concentration Units Environmental PM10.0 - */ - uint32 pm100_environmental = 6; - - /* - * 0.3um Particle Count - */ - uint32 particles_03um = 7; - - /* - * 0.5um Particle Count - */ - uint32 particles_05um = 8; - - /* - * 1.0um Particle Count - */ - uint32 particles_10um = 9; - - /* - * 2.5um Particle Count - */ - uint32 particles_25um = 10; - - /* - * 5.0um Particle Count - */ - uint32 particles_50um = 11; - - /* - * 10.0um Particle Count - */ - uint32 particles_100um = 12; -} - -/* - * Types of Measurements the telemetry module is equipped to handle - */ -message Telemetry { - /* - * Seconds since 1970 - or 0 for unknown/unset - */ - fixed32 time = 1; - - oneof variant { - /* - * Key native device metrics such as battery level - */ - DeviceMetrics device_metrics = 2; - - /* - * Weather station or other environmental metrics - */ - EnvironmentMetrics environment_metrics = 3; - - /* - * Air quality metrics - */ - AirQualityMetrics air_quality_metrics = 4; - - /* - * Power Metrics - */ - PowerMetrics power_metrics = 5; - } -} - -/* - * Supported I2C Sensors for telemetry in Meshtastic - */ -enum TelemetrySensorType { - /* - * No external telemetry sensor explicitly set - */ - SENSOR_UNSET = 0; - - /* - * High accuracy temperature, pressure, humidity - */ - BME280 = 1; - - /* - * High accuracy temperature, pressure, humidity, and air resistance - */ - BME680 = 2; - - /* - * Very high accuracy temperature - */ - MCP9808 = 3; - - /* - * Moderate accuracy current and voltage - */ - INA260 = 4; - - /* - * Moderate accuracy current and voltage - */ - INA219 = 5; - - /* - * High accuracy temperature and pressure - */ - BMP280 = 6; - - /* - * High accuracy temperature and humidity - */ - SHTC3 = 7; - - /* - * High accuracy pressure - */ - LPS22 = 8; - - /* - * 3-Axis magnetic sensor - */ - QMC6310 = 9; - - /* - * 6-Axis inertial measurement sensor - */ - QMI8658 = 10; - - /* - * 3-Axis magnetic sensor - */ - QMC5883L = 11; - - /* - * High accuracy temperature and humidity - */ - SHT31 = 12; - - /* - * PM2.5 air quality sensor - */ - PMSA003I = 13; - - /* - * INA3221 3 Channel Voltage / Current Sensor - */ - INA3221 = 14; - - /* - * BMP085/BMP180 High accuracy temperature and pressure (older Version of BMP280) - */ - BMP085 = 15; - - /* - * RCWL-9620 Doppler Radar Distance Sensor, used for water level detection - */ - RCWL9620 = 16; - - /* - * Sensirion High accuracy temperature and humidity - */ - SHT4X = 17; - - /* - * VEML7700 high accuracy ambient light(Lux) digital 16-bit resolution sensor. - */ - VEML7700 = 18; - - /* - * MLX90632 non-contact IR temperature sensor. - */ - MLX90632 = 19; - - /* - * TI OPT3001 Ambient Light Sensor - */ - OPT3001 = 20; - - /* - * Lite On LTR-390UV-01 UV Light Sensor - */ - LTR390UV = 21; - - /* - * AMS TSL25911FN RGB Light Sensor - */ - TSL25911FN = 22; - - /* - * AHT10 Integrated temperature and humidity sensor - */ - AHT10 = 23; - - /* - * DFRobot Lark Weather station (temperature, humidity, pressure, wind speed and direction) - */ - DFROBOT_LARK = 24; - - /* - * NAU7802 Scale Chip or compatible - */ - NAU7802 = 25; -} - -/* - * NAU7802 Telemetry configuration, for saving to flash - */ -message Nau7802Config { - /* - * The offset setting for the NAU7802 - */ - int32 zeroOffset = 1; - - /* - * The calibration factor for the NAU7802 - */ - float calibrationFactor = 2; -} +syntax = "proto3"; + +package meshtastic; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "TelemetryProtos"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; + +/* + * Key native device metrics such as battery level + */ +message DeviceMetrics { + /* + * 0-100 (>100 means powered) + */ + uint32 battery_level = 1; + + /* + * Voltage measured + */ + float voltage = 2; + + /* + * Utilization for the current channel, including well formed TX, RX and malformed RX (aka noise). + */ + float channel_utilization = 3; + + /* + * Percent of airtime for transmission used within the last hour. + */ + float air_util_tx = 4; + + /* + * How long the device has been running since the last reboot (in seconds) + */ + uint32 uptime_seconds = 5; +} + +/* + * Weather station or other environmental metrics + */ +message EnvironmentMetrics { + /* + * Temperature measured + */ + float temperature = 1; + + /* + * Relative humidity percent measured + */ + float relative_humidity = 2; + + /* + * Barometric pressure in hPA measured + */ + float barometric_pressure = 3; + + /* + * Gas resistance in MOhm measured + */ + float gas_resistance = 4; + + /* + * Voltage measured (To be depreciated in favor of PowerMetrics in Meshtastic 3.x) + */ + float voltage = 5; + + /* + * Current measured (To be depreciated in favor of PowerMetrics in Meshtastic 3.x) + */ + float current = 6; + + /* + * 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. + */ + uint32 iaq = 7; + + /* + * RCWL9620 Doppler Radar Distance Sensor, used for water level detection. Float value in mm. + */ + float distance = 8; + + /* + * VEML7700 high accuracy ambient light(Lux) digital 16-bit resolution sensor. + */ + float lux = 9; + + /* + * VEML7700 high accuracy white light(irradiance) not calibrated digital 16-bit resolution sensor. + */ + float white_lux = 10; + + /* + * Infrared lux + */ + float ir_lux = 11; + + /* + * Ultraviolet lux + */ + float uv_lux = 12; + + /* + * Wind direction in degrees + * 0 degrees = North, 90 = East, etc... + */ + uint32 wind_direction = 13; + + /* + * Wind speed in m/s + */ + float wind_speed = 14; + + /* + * Weight in KG + */ + float weight = 15; + + /* + * Wind gust in m/s + */ + float wind_gust = 16; + + /* + * Wind lull in m/s + */ + float wind_lull = 17; +} + +/* + * Power Metrics (voltage / current / etc) + */ +message PowerMetrics { + /* + * Voltage (Ch1) + */ + float ch1_voltage = 1; + + /* + * Current (Ch1) + */ + float ch1_current = 2; + + /* + * Voltage (Ch2) + */ + float ch2_voltage = 3; + + /* + * Current (Ch2) + */ + float ch2_current = 4; + + /* + * Voltage (Ch3) + */ + float ch3_voltage = 5; + + /* + * Current (Ch3) + */ + float ch3_current = 6; +} + +/* + * Air quality metrics + */ +message AirQualityMetrics { + /* + * Concentration Units Standard PM1.0 + */ + uint32 pm10_standard = 1; + + /* + * Concentration Units Standard PM2.5 + */ + uint32 pm25_standard = 2; + + /* + * Concentration Units Standard PM10.0 + */ + uint32 pm100_standard = 3; + + /* + * Concentration Units Environmental PM1.0 + */ + uint32 pm10_environmental = 4; + + /* + * Concentration Units Environmental PM2.5 + */ + uint32 pm25_environmental = 5; + + /* + * Concentration Units Environmental PM10.0 + */ + uint32 pm100_environmental = 6; + + /* + * 0.3um Particle Count + */ + uint32 particles_03um = 7; + + /* + * 0.5um Particle Count + */ + uint32 particles_05um = 8; + + /* + * 1.0um Particle Count + */ + uint32 particles_10um = 9; + + /* + * 2.5um Particle Count + */ + uint32 particles_25um = 10; + + /* + * 5.0um Particle Count + */ + uint32 particles_50um = 11; + + /* + * 10.0um Particle Count + */ + uint32 particles_100um = 12; +} + +/* + * Types of Measurements the telemetry module is equipped to handle + */ +message Telemetry { + /* + * Seconds since 1970 - or 0 for unknown/unset + */ + fixed32 time = 1; + + oneof variant { + /* + * Key native device metrics such as battery level + */ + DeviceMetrics device_metrics = 2; + + /* + * Weather station or other environmental metrics + */ + EnvironmentMetrics environment_metrics = 3; + + /* + * Air quality metrics + */ + AirQualityMetrics air_quality_metrics = 4; + + /* + * Power Metrics + */ + PowerMetrics power_metrics = 5; + } +} + +/* + * Supported I2C Sensors for telemetry in Meshtastic + */ +enum TelemetrySensorType { + /* + * No external telemetry sensor explicitly set + */ + SENSOR_UNSET = 0; + + /* + * High accuracy temperature, pressure, humidity + */ + BME280 = 1; + + /* + * High accuracy temperature, pressure, humidity, and air resistance + */ + BME680 = 2; + + /* + * Very high accuracy temperature + */ + MCP9808 = 3; + + /* + * Moderate accuracy current and voltage + */ + INA260 = 4; + + /* + * Moderate accuracy current and voltage + */ + INA219 = 5; + + /* + * High accuracy temperature and pressure + */ + BMP280 = 6; + + /* + * High accuracy temperature and humidity + */ + SHTC3 = 7; + + /* + * High accuracy pressure + */ + LPS22 = 8; + + /* + * 3-Axis magnetic sensor + */ + QMC6310 = 9; + + /* + * 6-Axis inertial measurement sensor + */ + QMI8658 = 10; + + /* + * 3-Axis magnetic sensor + */ + QMC5883L = 11; + + /* + * High accuracy temperature and humidity + */ + SHT31 = 12; + + /* + * PM2.5 air quality sensor + */ + PMSA003I = 13; + + /* + * INA3221 3 Channel Voltage / Current Sensor + */ + INA3221 = 14; + + /* + * BMP085/BMP180 High accuracy temperature and pressure (older Version of BMP280) + */ + BMP085 = 15; + + /* + * RCWL-9620 Doppler Radar Distance Sensor, used for water level detection + */ + RCWL9620 = 16; + + /* + * Sensirion High accuracy temperature and humidity + */ + SHT4X = 17; + + /* + * VEML7700 high accuracy ambient light(Lux) digital 16-bit resolution sensor. + */ + VEML7700 = 18; + + /* + * MLX90632 non-contact IR temperature sensor. + */ + MLX90632 = 19; + + /* + * TI OPT3001 Ambient Light Sensor + */ + OPT3001 = 20; + + /* + * Lite On LTR-390UV-01 UV Light Sensor + */ + LTR390UV = 21; + + /* + * AMS TSL25911FN RGB Light Sensor + */ + TSL25911FN = 22; + + /* + * AHT10 Integrated temperature and humidity sensor + */ + AHT10 = 23; + + /* + * DFRobot Lark Weather station (temperature, humidity, pressure, wind speed and direction) + */ + DFROBOT_LARK = 24; + + /* + * NAU7802 Scale Chip or compatible + */ + NAU7802 = 25; +} + +/* + * NAU7802 Telemetry configuration, for saving to flash + */ +message Nau7802Config { + /* + * The offset setting for the NAU7802 + */ + int32 zeroOffset = 1; + + /* + * The calibration factor for the NAU7802 + */ + float calibrationFactor = 2; +} From c1b0e1ef0797c9bd6b7e7491566c3f190308c021 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Tue, 6 Aug 2024 19:29:32 -0500 Subject: [PATCH 02/15] Short turbo preset --- meshtastic/config.proto | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/meshtastic/config.proto b/meshtastic/config.proto index d3756b5c..97aafcf2 100644 --- a/meshtastic/config.proto +++ b/meshtastic/config.proto @@ -825,8 +825,9 @@ message Config { /* * Very Long Range - Slow + * Deprecated in 2.5: Works only with txco and is unusably slow */ - VERY_LONG_SLOW = 2; + VERY_LONG_SLOW = 2 [deprecated = true]; /* * Medium Range - Slow @@ -852,6 +853,13 @@ message Config { * Long Range - Moderately Fast */ LONG_MODERATE = 7; + + /* + * Short Range - Turbo + * This is the fastest preset and the only one with 500kHz bandwidth. + * It is not legal to use in all regions due to this wider bandwidth. + */ + SHORT_TURBO = 8; } /* From 020140ca57b8c9ae70fc73f4688e5f9817b89630 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Tue, 6 Aug 2024 17:37:33 -0700 Subject: [PATCH 03/15] Add `optional` keywords to stuff that can be "truly zero" within mesh packet payloads --- meshtastic/mesh.proto | 18 ++++---- meshtastic/module_config.proto | 1 + meshtastic/telemetry.proto | 80 +++++++++++++++++----------------- 3 files changed, 50 insertions(+), 49 deletions(-) diff --git a/meshtastic/mesh.proto b/meshtastic/mesh.proto index c8bd2eff..ad8b25e1 100644 --- a/meshtastic/mesh.proto +++ b/meshtastic/mesh.proto @@ -23,17 +23,17 @@ message Position { * The new preferred location encoding, multiply by 1e-7 to get degrees * in floating point */ - sfixed32 latitude_i = 1; + optional sfixed32 latitude_i = 1; /* * TODO: REPLACE */ - sfixed32 longitude_i = 2; + optional sfixed32 longitude_i = 2; /* * In meters above MSL (but see issue #359) */ - int32 altitude = 3; + optional int32 altitude = 3; /* * This is usually not sent over the mesh (to save space), but it is sent @@ -122,12 +122,12 @@ message Position { /* * HAE altitude in meters - can be used instead of MSL altitude */ - sint32 altitude_hae = 9; + optional sint32 altitude_hae = 9; /* * Geoidal separation in meters */ - sint32 altitude_geoidal_separation = 10; + optional sint32 altitude_geoidal_separation = 10; /* * Horizontal, Vertical and Position Dilution of Precision, in 1/100 units @@ -163,12 +163,12 @@ message Position { * - "yaw" indicates a relative rotation about the vertical axis * TODO: REMOVE/INTEGRATE */ - uint32 ground_speed = 15; + optional uint32 ground_speed = 15; /* * TODO: REPLACE */ - uint32 ground_track = 16; + optional uint32 ground_track = 16; /* * GPS fix quality (from NMEA GxGGA statement or similar) @@ -837,12 +837,12 @@ message Waypoint { /* * latitude_i */ - sfixed32 latitude_i = 2; + optional sfixed32 latitude_i = 2; /* * longitude_i */ - sfixed32 longitude_i = 3; + optional sfixed32 longitude_i = 3; /* * Time the waypoint is to expire (epoch) diff --git a/meshtastic/module_config.proto b/meshtastic/module_config.proto index 38793736..02814159 100644 --- a/meshtastic/module_config.proto +++ b/meshtastic/module_config.proto @@ -153,6 +153,7 @@ message ModuleConfig { * Works as a sort of status heartbeat for peace of mind */ uint32 state_broadcast_secs = 3; + /* * Send ASCII bell with alert message * Useful for triggering ext. notification on bell diff --git a/meshtastic/telemetry.proto b/meshtastic/telemetry.proto index ffea320e..001c4576 100644 --- a/meshtastic/telemetry.proto +++ b/meshtastic/telemetry.proto @@ -15,27 +15,27 @@ message DeviceMetrics { /* * 0-100 (>100 means powered) */ - uint32 battery_level = 1; + optional uint32 battery_level = 1; /* * Voltage measured */ - float voltage = 2; + optional float voltage = 2; /* * Utilization for the current channel, including well formed TX, RX and malformed RX (aka noise). */ - float channel_utilization = 3; + optional float channel_utilization = 3; /* * Percent of airtime for transmission used within the last hour. */ - float air_util_tx = 4; + optional float air_util_tx = 4; /* * How long the device has been running since the last reboot (in seconds) */ - uint32 uptime_seconds = 5; + optional uint32 uptime_seconds = 5; } /* @@ -45,89 +45,89 @@ message EnvironmentMetrics { /* * Temperature measured */ - float temperature = 1; + optional float temperature = 1; /* * Relative humidity percent measured */ - float relative_humidity = 2; + optional float relative_humidity = 2; /* * Barometric pressure in hPA measured */ - float barometric_pressure = 3; + optional float barometric_pressure = 3; /* * Gas resistance in MOhm measured */ - float gas_resistance = 4; + optional float gas_resistance = 4; /* * Voltage measured (To be depreciated in favor of PowerMetrics in Meshtastic 3.x) */ - float voltage = 5; + optional float voltage = 5; /* * Current measured (To be depreciated in favor of PowerMetrics in Meshtastic 3.x) */ - float current = 6; + optional float current = 6; /* * 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. */ - uint32 iaq = 7; + optional uint32 iaq = 7; /* * RCWL9620 Doppler Radar Distance Sensor, used for water level detection. Float value in mm. */ - float distance = 8; + optional float distance = 8; /* * VEML7700 high accuracy ambient light(Lux) digital 16-bit resolution sensor. */ - float lux = 9; + optional float lux = 9; /* * VEML7700 high accuracy white light(irradiance) not calibrated digital 16-bit resolution sensor. */ - float white_lux = 10; + optional float white_lux = 10; /* * Infrared lux */ - float ir_lux = 11; + optional float ir_lux = 11; /* * Ultraviolet lux */ - float uv_lux = 12; + optional float uv_lux = 12; /* * Wind direction in degrees * 0 degrees = North, 90 = East, etc... */ - uint32 wind_direction = 13; + optional uint32 wind_direction = 13; /* * Wind speed in m/s */ - float wind_speed = 14; + optional float wind_speed = 14; /* * Weight in KG */ - float weight = 15; + optional float weight = 15; /* * Wind gust in m/s */ - float wind_gust = 16; + optional float wind_gust = 16; /* * Wind lull in m/s */ - float wind_lull = 17; + optional float wind_lull = 17; } /* @@ -137,32 +137,32 @@ message PowerMetrics { /* * Voltage (Ch1) */ - float ch1_voltage = 1; + optional float ch1_voltage = 1; /* * Current (Ch1) */ - float ch1_current = 2; + optional float ch1_current = 2; /* * Voltage (Ch2) */ - float ch2_voltage = 3; + optional float ch2_voltage = 3; /* * Current (Ch2) */ - float ch2_current = 4; + optional float ch2_current = 4; /* * Voltage (Ch3) */ - float ch3_voltage = 5; + optional float ch3_voltage = 5; /* * Current (Ch3) */ - float ch3_current = 6; + optional float ch3_current = 6; } /* @@ -172,62 +172,62 @@ message AirQualityMetrics { /* * Concentration Units Standard PM1.0 */ - uint32 pm10_standard = 1; + optional uint32 pm10_standard = 1; /* * Concentration Units Standard PM2.5 */ - uint32 pm25_standard = 2; + optional uint32 pm25_standard = 2; /* * Concentration Units Standard PM10.0 */ - uint32 pm100_standard = 3; + optional uint32 pm100_standard = 3; /* * Concentration Units Environmental PM1.0 */ - uint32 pm10_environmental = 4; + optional uint32 pm10_environmental = 4; /* * Concentration Units Environmental PM2.5 */ - uint32 pm25_environmental = 5; + optional uint32 pm25_environmental = 5; /* * Concentration Units Environmental PM10.0 */ - uint32 pm100_environmental = 6; + optional uint32 pm100_environmental = 6; /* * 0.3um Particle Count */ - uint32 particles_03um = 7; + optional uint32 particles_03um = 7; /* * 0.5um Particle Count */ - uint32 particles_05um = 8; + optional uint32 particles_05um = 8; /* * 1.0um Particle Count */ - uint32 particles_10um = 9; + optional uint32 particles_10um = 9; /* * 2.5um Particle Count */ - uint32 particles_25um = 10; + optional uint32 particles_25um = 10; /* * 5.0um Particle Count */ - uint32 particles_50um = 11; + optional uint32 particles_50um = 11; /* * 10.0um Particle Count */ - uint32 particles_100um = 12; + optional uint32 particles_100um = 12; } /* From d55be9e85518f86bcadd56636b283146a5c40286 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sun, 4 Aug 2024 22:36:33 -0500 Subject: [PATCH 04/15] Adds public_key and private_key for PKI co-authored-by: edinnen --- meshtastic/mesh.options | 2 ++ meshtastic/mesh.proto | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/meshtastic/mesh.options b/meshtastic/mesh.options index 7075e2da..32a31042 100644 --- a/meshtastic/mesh.options +++ b/meshtastic/mesh.options @@ -3,6 +3,8 @@ *macaddr max_size:6 fixed_length:true # macaddrs *id max_size:16 # node id strings +*public_key max_size:32 # public key +*private_key max_size:32 # private key *User.long_name max_size:40 *User.short_name max_size:5 diff --git a/meshtastic/mesh.proto b/meshtastic/mesh.proto index c8bd2eff..2aa92f82 100644 --- a/meshtastic/mesh.proto +++ b/meshtastic/mesh.proto @@ -665,6 +665,12 @@ message User { * Indicates that the user's role in the mesh */ Config.DeviceConfig.Role role = 7; + + /* + * The public key of the user's device. + * This is sent out to other nodes on the mesh to allow them to compute a shared secret key. + */ + bytes public_key = 8; } /* @@ -1329,6 +1335,12 @@ message MyNodeInfo { * Phone/PC apps should compare this to their build number and if too low tell the user they must update their app */ uint32 min_app_version = 11; + + /* + * The private key of the device. + * This is used to create a shared key with a remote device. + */ + bytes private_key = 12; } /* From 905d712f2ae75b9527fb536aec51f0959cc832f6 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Mon, 5 Aug 2024 12:04:21 -0500 Subject: [PATCH 05/15] Add the key used to PKI decrypt to MeshPacket --- meshtastic/mesh.proto | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/meshtastic/mesh.proto b/meshtastic/mesh.proto index 2aa92f82..3193d9f6 100644 --- a/meshtastic/mesh.proto +++ b/meshtastic/mesh.proto @@ -1111,6 +1111,16 @@ message MeshPacket { * When receiving a packet, the difference between hop_start and hop_limit gives how many hops it traveled. */ uint32 hop_start = 15; + + /* + * Records the public key the packet was encrypted with, if applicable. + */ + bytes public_key = 16; + + /* + * Indicates whether the packet was en/decrypted using PKI + */ + bool pki_encrypted = 17; } /* From 1e1c4d93ddf6da24c08fd4a68ef337944475c38d Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Tue, 6 Aug 2024 20:35:38 -0500 Subject: [PATCH 06/15] Re-org some settings into a new SecurityConfig proto --- meshtastic/config.options | 4 ++++ meshtastic/config.proto | 48 ++++++++++++++++++++++++++++++++++++--- meshtastic/mesh.options | 1 - meshtastic/mesh.proto | 6 ----- 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/meshtastic/config.options b/meshtastic/config.options index 22dcc88a..704d1411 100644 --- a/meshtastic/config.options +++ b/meshtastic/config.options @@ -15,3 +15,7 @@ *LoRaConfig.channel_num int_size:16 *PowerConfig.device_battery_ina_address int_size:8 + +*SecurityConfig.public_key max_size:32 +*SecurityConfig.private_key max_size:32 +*SecurityConfig.admin_key max_size:32 diff --git a/meshtastic/config.proto b/meshtastic/config.proto index d3756b5c..515ed984 100644 --- a/meshtastic/config.proto +++ b/meshtastic/config.proto @@ -135,14 +135,16 @@ message Config { /* * Disabling this will disable the SerialConsole by not initilizing the StreamAPI + * Moved to SecurityConfig */ - bool serial_enabled = 2; + bool serial_enabled = 2[deprecated = true]; /* * By default we turn off logging as soon as an API client connects (to keep shared serial link quiet). * Set this to true to leave the debug log outputting even when API is active. + * Moved to SecurityConfig */ - bool debug_log_enabled = 3; + bool debug_log_enabled = 3[deprecated = true]; /* * For boards without a hard wired button, this is the pin number that will be used @@ -175,8 +177,9 @@ message Config { /* * If true, device is considered to be "managed" by a mesh administrator * Clients should then limit available configuration and administrative options inside the user interface + * Moved to SecurityConfig */ - bool is_managed = 9; + bool is_managed = 9[deprecated = true]; /* * Disables the triple-press of user button to enable or disable GPS @@ -1010,6 +1013,44 @@ message Config { bool device_logging_enabled = 4; } + message SecurityConfig { + + /* + * The public key of the user's device. + * This is sent out to other nodes on the mesh to allow them to compute a shared secret key. + */ + bytes public_key = 1; + + /* + * The private key of the device. + * This is used to create a shared key with a remote device. + */ + bytes private_key = 2; + + /* + * This is the public key authorized to send admin messages to this node + */ + bytes admin_key = 3; + + /* + * If true, device is considered to be "managed" by a mesh administrator + * Clients should then limit available configuration and administrative options inside the user interface + */ + bool is_managed = 4; + + /* + * Disabling this will disable the SerialConsole by not initilizing the StreamAPI + */ + bool serial_enabled = 5; + + /* + * By default we turn off logging as soon as an API client connects (to keep shared serial link quiet). + * Set this to true to leave the debug log outputting even when API is active. + */ + bool debug_log_enabled = 6; + + } + /* * Payload Variant */ @@ -1021,5 +1062,6 @@ message Config { DisplayConfig display = 5; LoRaConfig lora = 6; BluetoothConfig bluetooth = 7; + SecurityConfig security = 8; } } diff --git a/meshtastic/mesh.options b/meshtastic/mesh.options index 32a31042..872e310a 100644 --- a/meshtastic/mesh.options +++ b/meshtastic/mesh.options @@ -4,7 +4,6 @@ *macaddr max_size:6 fixed_length:true # macaddrs *id max_size:16 # node id strings *public_key max_size:32 # public key -*private_key max_size:32 # private key *User.long_name max_size:40 *User.short_name max_size:5 diff --git a/meshtastic/mesh.proto b/meshtastic/mesh.proto index 3193d9f6..5068ab47 100644 --- a/meshtastic/mesh.proto +++ b/meshtastic/mesh.proto @@ -1345,12 +1345,6 @@ message MyNodeInfo { * Phone/PC apps should compare this to their build number and if too low tell the user they must update their app */ uint32 min_app_version = 11; - - /* - * The private key of the device. - * This is used to create a shared key with a remote device. - */ - bytes private_key = 12; } /* From 951cca0f353406d36c192e405ecabd8559e3ed90 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Tue, 6 Aug 2024 20:52:57 -0500 Subject: [PATCH 07/15] Also move device_logging_enabled from bluetooth to SecurityConfig --- meshtastic/config.proto | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/meshtastic/config.proto b/meshtastic/config.proto index 515ed984..ab54438c 100644 --- a/meshtastic/config.proto +++ b/meshtastic/config.proto @@ -1009,8 +1009,9 @@ message Config { /* * Enables device (serial style logs) over Bluetooth + * Moved to SecurityConfig */ - bool device_logging_enabled = 4; + bool device_logging_enabled = 4[deprecated = true]; } message SecurityConfig { @@ -1049,6 +1050,11 @@ message Config { */ bool debug_log_enabled = 6; + /* + * Enables device (serial style logs) over Bluetooth + * Moved to SecurityConfig + */ + bool bluetooth_logging_enabled = 7; } /* From 1696cdf742582e34bd97f8f81fb9367275a0927a Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Tue, 6 Aug 2024 21:01:46 -0500 Subject: [PATCH 08/15] Add SecurityConfig to Localonly --- meshtastic/localonly.proto | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/meshtastic/localonly.proto b/meshtastic/localonly.proto index 9694d7b4..bcb27964 100644 --- a/meshtastic/localonly.proto +++ b/meshtastic/localonly.proto @@ -58,6 +58,11 @@ message LocalConfig { * NodeDB.cpp in the device code. */ uint32 version = 8; + + /* + * The part of the config that is specific to Security settings + */ + Config.SecurityConfig security = 9; } message LocalModuleConfig { From f5a12c0cfd1d7a0ca349dedffc67f3aa7512d2ab Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Wed, 7 Aug 2024 09:28:57 -0500 Subject: [PATCH 09/15] Add admin_channel_enabled to the security config --- meshtastic/config.proto | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/meshtastic/config.proto b/meshtastic/config.proto index ab54438c..e38fb4c3 100644 --- a/meshtastic/config.proto +++ b/meshtastic/config.proto @@ -1055,6 +1055,11 @@ message Config { * Moved to SecurityConfig */ bool bluetooth_logging_enabled = 7; + + /* + * Enables incoming admin control over the "admin" channel + */ + bool admin_channel_enabled = 8 [default = false]; } /* From 81fd9d374f1b364c2812b7a0ca2784a7605b6835 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Wed, 7 Aug 2024 09:38:52 -0500 Subject: [PATCH 10/15] No default for you, Proto3 --- meshtastic/config.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meshtastic/config.proto b/meshtastic/config.proto index e38fb4c3..d9bffd64 100644 --- a/meshtastic/config.proto +++ b/meshtastic/config.proto @@ -1059,7 +1059,7 @@ message Config { /* * Enables incoming admin control over the "admin" channel */ - bool admin_channel_enabled = 8 [default = false]; + bool admin_channel_enabled = 8; } /* From 4d9da7a6454bcb1e565aedfb56e9277b58186ea3 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 8 Aug 2024 06:52:25 -0500 Subject: [PATCH 11/15] Add client notification fromradio message --- meshtastic/mesh.options | 2 ++ meshtastic/mesh.proto | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/meshtastic/mesh.options b/meshtastic/mesh.options index 7075e2da..828238e0 100644 --- a/meshtastic/mesh.options +++ b/meshtastic/mesh.options @@ -45,6 +45,8 @@ *FileInfo.file_name max_size:228 +*ClientNotification.message max_size:400 + # MyMessage.name max_size:40 # or fixed_length or fixed_count, or max_count diff --git a/meshtastic/mesh.proto b/meshtastic/mesh.proto index c8bd2eff..5b599cd6 100644 --- a/meshtastic/mesh.proto +++ b/meshtastic/mesh.proto @@ -1508,9 +1508,41 @@ message FromRadio { * File system manifest messages */ FileInfo fileInfo = 15; + + /* + * Notification message to the client + */ + ClientNotification clientNotification = 16; } } +/* + * A notification message from the device to the client + * To be used for important messages that should to be displayed to the user + * in the form of push notifications or validation messages when saving + * invalid configuration. + */ +message ClientNotification { + /* + * The id of the packet we're notifying in response to + */ + optional uint32 reply_id = 1; + + /* + * Seconds since 1970 - or 0 for unknown/unset + */ + fixed32 time = 2; + + /* + * The level type of notification + */ + LogRecord.Level level = 3; + /* + * The message body of the notification + */ + string message = 4; +} + /* * Individual File info for the device */ From 4e58f9e70405c45c4e4ed224ae18305f05cc80f5 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Thu, 8 Aug 2024 06:55:51 -0700 Subject: [PATCH 12/15] Update config.proto Update comments to match discord conversation --- meshtastic/config.proto | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/meshtastic/config.proto b/meshtastic/config.proto index d9bffd64..36fa2b29 100644 --- a/meshtastic/config.proto +++ b/meshtastic/config.proto @@ -1018,46 +1018,45 @@ message Config { /* * The public key of the user's device. - * This is sent out to other nodes on the mesh to allow them to compute a shared secret key. + * Sent out to other nodes on the mesh to allow them to compute a shared secret key. */ bytes public_key = 1; /* * The private key of the device. - * This is used to create a shared key with a remote device. + * Used to create a shared key with a remote device. */ bytes private_key = 2; /* - * This is the public key authorized to send admin messages to this node + * The public key authorized to send admin messages to this node. */ bytes admin_key = 3; /* - * If true, device is considered to be "managed" by a mesh administrator - * Clients should then limit available configuration and administrative options inside the user interface + * If true, device is considered to be "managed" by a mesh administrator via admin messages + * Device is managed by a mesh administrator. */ bool is_managed = 4; /* - * Disabling this will disable the SerialConsole by not initilizing the StreamAPI + * Serial Console over the Stream API." */ bool serial_enabled = 5; /* * By default we turn off logging as soon as an API client connects (to keep shared serial link quiet). - * Set this to true to leave the debug log outputting even when API is active. + * Output live debug logging over serial. */ bool debug_log_enabled = 6; /* * Enables device (serial style logs) over Bluetooth - * Moved to SecurityConfig */ bool bluetooth_logging_enabled = 7; /* - * Enables incoming admin control over the "admin" channel + * Allow incoming device control over the insecure legacy admin channel. */ bool admin_channel_enabled = 8; } From b332e0759c2ca3d35d479e241b9a00c943f163e2 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Thu, 8 Aug 2024 08:10:02 -0700 Subject: [PATCH 13/15] Update config.proto update api name --- meshtastic/config.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meshtastic/config.proto b/meshtastic/config.proto index 36fa2b29..603a679b 100644 --- a/meshtastic/config.proto +++ b/meshtastic/config.proto @@ -1048,7 +1048,7 @@ message Config { * By default we turn off logging as soon as an API client connects (to keep shared serial link quiet). * Output live debug logging over serial. */ - bool debug_log_enabled = 6; + bool debug_log_api_enabled = 6; /* * Enables device (serial style logs) over Bluetooth From 66eb3184d5651705ae62f80bf4f65b94a62e7f06 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sat, 10 Aug 2024 22:58:01 -0500 Subject: [PATCH 14/15] Add SECURITY_CONFIG to admin.proto (#547) --- meshtastic/admin.proto | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/meshtastic/admin.proto b/meshtastic/admin.proto index 12fe0c74..1c637c9f 100644 --- a/meshtastic/admin.proto +++ b/meshtastic/admin.proto @@ -58,6 +58,11 @@ message AdminMessage { * TODO: REPLACE */ BLUETOOTH_CONFIG = 6; + + /* + * TODO: REPLACE + */ + SECURITY_CONFIG = 7; } /* From 9f02bf797c203fd4178098a5571063165e4c8281 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sun, 11 Aug 2024 14:38:10 -0500 Subject: [PATCH 15/15] add PKI uplink and downlink options Addresses #4428 --- meshtastic/config.proto | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/meshtastic/config.proto b/meshtastic/config.proto index 47900e66..98c0e66e 100644 --- a/meshtastic/config.proto +++ b/meshtastic/config.proto @@ -1067,6 +1067,16 @@ message Config { * Allow incoming device control over the insecure legacy admin channel. */ bool admin_channel_enabled = 8; + + /* + * If true, messages on the mesh will be sent to the *public* internet by any gateway ndoe + */ + bool pki_uplink_enabled = 9; + + /* + * If true, messages seen on the internet will be forwarded to the local mesh. + */ + bool pki_downlink_enabled = 10; } /*