From 47d502b9c561ba0ac37a6c68fac9631eaca066a1 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 26 Mar 2022 14:09:18 -0500 Subject: [PATCH 01/10] Split device and environment metrics --- telemetry.options | 4 +++ telemetry.proto | 69 ++++++++++++++++++++++++++++++++++------------- 2 files changed, 54 insertions(+), 19 deletions(-) create mode 100644 telemetry.options diff --git a/telemetry.options b/telemetry.options new file mode 100644 index 0000000..6c80df9 --- /dev/null +++ b/telemetry.options @@ -0,0 +1,4 @@ +# options for nanopb +# https://jpa.kapsi.fi/nanopb/docs/reference.html#proto-file-options + + diff --git a/telemetry.proto b/telemetry.proto index 03038a3..e9f1099 100644 --- a/telemetry.proto +++ b/telemetry.proto @@ -1,30 +1,30 @@ syntax = "proto3"; + +option java_package = "com.geeksville.mesh"; +option optimize_for = LITE_RUNTIME; option go_package = "github.com/meshtastic/gomeshproto"; +option java_outer_classname = "TelemetryProtos"; + /* - * TODO: REPLACE + * Key native device metrics such as battery level */ -message Telemetry { - - /* - * This is usually not sent over the mesh (to save space), but it is sent - * from the phone so that the local device can set its RTC If it is sent over - * the mesh (because there are devices on the mesh without GPS), it will only - * be sent by devices which has a hardware GPS clock (IE Mobile Phone). - * seconds since 1970 - */ - fixed32 time = 1; - +message DeviceMetrics { /* * 1-100 (0 means powered) */ - uint32 battery_level = 2; + 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. */ @@ -35,34 +35,65 @@ message Telemetry { * and is not being sent as a reliable message. */ bool router_heartbeat = 5; +} +/* + * Weather station or other environmental metrics + */ +message EnvironmentMetrics { /* * Temperature measured */ - float temperature = 6; + float temperature = 1; /* * Relative humidity percent measured */ - float relative_humidity = 7; + float relative_humidity = 2; /* * Barometric pressure in hPA measured */ - float barometric_pressure = 8; + float barometric_pressure = 3; /* * Gas resistance in mOhm measured */ - float gas_resistance = 9; + float gas_resistance = 4; /* * Voltage measured */ - float voltage = 10; + float voltage = 10; /* * Current measured */ float current = 11; } + +/* + * Types of Measurements the telemetry module is equipped to handle + */ +message Telemetry { + /* + * This is usually not sent over the mesh (to save space), but it is sent + * from the phone so that the local device can set its RTC If it is sent over + * the mesh (because there are devices on the mesh without GPS), it will only + * be sent by devices which has a hardware GPS clock (IE Mobile Phone). + * seconds since 1970 + */ + 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; + } +} From 8ea037476d2ca31a08c553a6a59f0e5249681d08 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 26 Mar 2022 14:25:48 -0500 Subject: [PATCH 02/10] Distinct prefs for environment and device --- radioconfig.proto | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/radioconfig.proto b/radioconfig.proto index 8a46c6e..f4fc151 100644 --- a/radioconfig.proto +++ b/radioconfig.proto @@ -741,29 +741,29 @@ message RadioConfig { reserved 136; /* - * Preferences for the Teletry Module + * Preferences for the Telemetry Module (Environment) * FIXME - Move this out of UserPreferences and into a section for module configuration. * Enable/Disable the telemetry measurement module measurement collection */ - bool telemetry_module_measurement_enabled = 140; + bool telemetry_module_environment_measurement_enabled = 140; /* * Enable/Disable the telemetry measurement module on-device display */ - bool telemetry_module_screen_enabled = 141; + bool telemetry_module_environment_screen_enabled = 141; /* * Sometimes sensor reads can fail. * If this happens, we will retry a configurable number of attempts, * each attempt will be delayed by the minimum required refresh rate for that sensor */ - uint32 telemetry_module_read_error_count_threshold = 142; + uint32 telemetry_module_environment_read_error_count_threshold = 142; /* * Interval in seconds of how often we should try to send our * measurements to the mesh */ - uint32 telemetry_module_update_interval = 143; + uint32 telemetry_module_device_update_interval = 143; /* * Sometimes we can end up with more than read_error_count_threshold failures. @@ -968,6 +968,12 @@ message RadioConfig { * Overrides the ADC_MULTIPLIER defined in variant for battery voltage calculation. */ float adc_multiplier_override = 175; + + /* + * Interval in seconds of how often we should try to send our + * environent measurements to the mesh + */ + uint32 telemetry_module_environment_update_interval = 176; } /* From e3b2aeab5047f77fe3e72aa8637aee6b8b70e91d Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 26 Mar 2022 14:30:35 -0500 Subject: [PATCH 03/10] Spacing --- telemetry.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/telemetry.proto b/telemetry.proto index e9f1099..f1dbb68 100644 --- a/telemetry.proto +++ b/telemetry.proto @@ -18,7 +18,7 @@ message DeviceMetrics { /* * Voltage measured */ - float voltage = 2; + float voltage = 2; /* * Utilization for the current channel, including well formed TX, RX and malformed RX (aka noise). @@ -64,7 +64,7 @@ message EnvironmentMetrics { /* * Voltage measured */ - float voltage = 10; + float voltage = 10; /* * Current measured From 17795f9be786b1a7a09d49e9d64a5cb434de0b09 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 26 Mar 2022 14:34:37 -0500 Subject: [PATCH 04/10] Space --- radioconfig.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radioconfig.proto b/radioconfig.proto index f4fc151..ebe587c 100644 --- a/radioconfig.proto +++ b/radioconfig.proto @@ -973,7 +973,7 @@ message RadioConfig { * Interval in seconds of how often we should try to send our * environent measurements to the mesh */ - uint32 telemetry_module_environment_update_interval = 176; + uint32 telemetry_module_environment_update_interval = 176; } /* From 4fb1330c73e5ae05cb9d97448e66c9a308c771c0 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 26 Mar 2022 14:41:53 -0500 Subject: [PATCH 05/10] Reindex values --- telemetry.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/telemetry.proto b/telemetry.proto index f1dbb68..82be278 100644 --- a/telemetry.proto +++ b/telemetry.proto @@ -64,12 +64,12 @@ message EnvironmentMetrics { /* * Voltage measured */ - float voltage = 10; + float voltage = 5; /* * Current measured */ - float current = 11; + float current = 6; } /* From dd0b91ffbb3602949e8f85dacfb43cb3b99f2e80 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 26 Mar 2022 15:16:09 -0500 Subject: [PATCH 06/10] Remove router heartbeat --- telemetry.proto | 6 ------ 1 file changed, 6 deletions(-) diff --git a/telemetry.proto b/telemetry.proto index 82be278..1c36be7 100644 --- a/telemetry.proto +++ b/telemetry.proto @@ -29,12 +29,6 @@ message DeviceMetrics { * Percent of airtime for transmission used within the last hour. */ float air_util_tx = 4; - - /* - * This is sent by node only if it a router and if hop_limit is set to 0 - * and is not being sent as a reliable message. - */ - bool router_heartbeat = 5; } /* From 8f33fbdb26ee5c45118746944ca3386fcc838dd5 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 26 Mar 2022 17:49:01 -0500 Subject: [PATCH 07/10] Fixed conflict --- radioconfig.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radioconfig.proto b/radioconfig.proto index ebe587c..1bf4582 100644 --- a/radioconfig.proto +++ b/radioconfig.proto @@ -973,7 +973,7 @@ message RadioConfig { * Interval in seconds of how often we should try to send our * environent measurements to the mesh */ - uint32 telemetry_module_environment_update_interval = 176; + uint32 telemetry_module_environment_update_interval = 177; } /* From 76d4e35fe4c7b9f226e63ad28c4ea3688090981d Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 26 Mar 2022 18:01:42 -0500 Subject: [PATCH 08/10] Environment rename --- radioconfig.proto | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/radioconfig.proto b/radioconfig.proto index 1bf4582..5c13e4e 100644 --- a/radioconfig.proto +++ b/radioconfig.proto @@ -770,13 +770,13 @@ message RadioConfig { * In this case, we will stop trying to read from the sensor for a while. * Wait this long until trying to read from the sensor again */ - uint32 telemetry_module_recovery_interval = 144; + uint32 telemetry_module_environment_recovery_interval = 144; /* * We'll always read the sensor in Celsius, but sometimes we might want to * display the results in Fahrenheit as a "user preference". */ - bool telemetry_module_display_fahrenheit = 145; + bool telemetry_module_environment_display_fahrenheit = 145; /* * TODO: REPLACE @@ -835,12 +835,12 @@ message RadioConfig { /* * Specify the sensor type */ - TelemetrySensorType telemetry_module_sensor_type = 146; + TelemetrySensorType telemetry_module_environment_sensor_type = 146; /* * Specify the peferred GPIO Pin for sensor readings */ - uint32 telemetry_module_sensor_pin = 147; + uint32 telemetry_module_environment_sensor_pin = 147; /* * Bit field of boolean configuration options for POSITION messages From 0a4e99a151eca110995c5e39acbc9394b0b98b44 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sun, 27 Mar 2022 08:06:19 -0500 Subject: [PATCH 09/10] Comment distinction --- mesh.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh.proto b/mesh.proto index 8e6a4ec..30aaffe 100644 --- a/mesh.proto +++ b/mesh.proto @@ -1053,7 +1053,7 @@ message NodeInfo { */ fixed32 last_heard = 5; /* - * The latest telemetry data for the node. + * The latest device telemetry data for the node. */ Telemetry telemetry = 6; } From e46d5b099da003870ead6f7f670a738f84ea3ba8 Mon Sep 17 00:00:00 2001 From: Sacha Weatherstone Date: Wed, 30 Mar 2022 14:02:26 +1100 Subject: [PATCH 10/10] Fix spaces --- cannedmessages.proto | 19 ------------------ channel.proto | 22 --------------------- mesh.proto | 46 ------------------------------------------- notused/future.proto | 1 - portnums.proto | 5 ----- radioconfig.proto | 26 ------------------------ remote_hardware.proto | 3 --- 7 files changed, 122 deletions(-) diff --git a/cannedmessages.proto b/cannedmessages.proto index 4b4f599..f5ed4b5 100644 --- a/cannedmessages.proto +++ b/cannedmessages.proto @@ -1,23 +1,4 @@ syntax = "proto3"; -/* - * Meshtastic protobufs - * - * For more information on protobufs (and tools to use them with the language of your choice) see - * https://developers.google.com/protocol-buffers/docs/proto3 - * - * We are not placing any of these defs inside a package, because if you do the - * resulting nanopb version is super verbose package mesh. - * - * Protobuf build instructions: - * - * To build java classes for reading writing: - * protoc -I=. --java_out /tmp mesh.proto - * - * To generate Nanopb c code: - * /home/kevinh/packages/nanopb-0.4.0-linux-x86/generator-bin/protoc --nanopb_out=/tmp -I=app/src/main/proto mesh.proto - * - * Nanopb binaries available here: https://jpa.kapsi.fi/nanopb/download/ use nanopb 0.4.0 - */ option java_package = "com.geeksville.mesh"; option java_outer_classname = "CannedMessageConfigProtos"; diff --git a/channel.proto b/channel.proto index 5dc480f..dcbfcbe 100644 --- a/channel.proto +++ b/channel.proto @@ -1,23 +1,4 @@ syntax = "proto3"; -/* - * Meshtastic protobufs - * - * For more information on protobufs (and tools to use them with the language of your choice) see - * https://developers.google.com/protocol-buffers/docs/proto3 - * - * We are not placing any of these defs inside a package, because if you do the - * resulting nanopb version is super verbose package mesh. - * - * Protobuf build instructions: - * - * To build java classes for reading writing: - * protoc -I=. --java_out /tmp mesh.proto - * - * To generate Nanopb c code: - * /home/kevinh/packages/nanopb-0.4.0-linux-x86/generator-bin/protoc --nanopb_out=/tmp -I=app/src/main/proto mesh.proto - * - * Nanopb binaries available here: https://jpa.kapsi.fi/nanopb/download/ use nanopb 0.4.0 - */ option java_package = "com.geeksville.mesh"; @@ -43,7 +24,6 @@ option java_outer_classname = "ChannelProtos"; * users COULD type in a channel name and be able to talk. * Y is a lower case letter from a-z that represents the channel 'speed' settings * (for some future definition of speed) - * * FIXME: Add description of multi-channel support and how primary vs secondary channels are used. * FIXME: explain how apps use channels for security. * explain how remote settings and remote gpio are managed as an example @@ -210,12 +190,10 @@ message Channel { /* * How this channel is being used (or not). - * * Note: this field is an enum to give us options for the future. * In particular, someday we might make a 'SCANNING' option. * SCANNING channels could have different frequencies and the radio would * occasionally check that freq to see if anything is being transmitted. - * * For devices that have multiple physical radios attached, we could keep multiple PRIMARY/SCANNING channels active at once to allow * cross band routing as needed. * If a device has only a single radio (the common case) only one channel can be PRIMARY at a time diff --git a/mesh.proto b/mesh.proto index 30aaffe..211bb2c 100644 --- a/mesh.proto +++ b/mesh.proto @@ -1,23 +1,4 @@ syntax = "proto3"; -/* - * Meshtastic protobufs - * - * For more information on protobufs (and tools to use them with the language of your choice) see - * https://developers.google.com/protocol-buffers/docs/proto3 - * - * We are not placing any of these defs inside a package, because if you do the - * resulting nanopb version is super verbose package mesh. - * - * Protobuf build instructions: - * - * To build java classes for reading writing: - * protoc -I=. --java_out /tmp mesh.proto - * - * To generate Nanopb c code: - * /home/kevinh/packages/nanopb-0.4.0-linux-x86/generator-bin/protoc --nanopb_out=/tmp -I=app/src/main/proto mesh.proto - * - * Nanopb binaries available here: https://jpa.kapsi.fi/nanopb/download/ use nanopb 0.4.0 - */ option java_package = "com.geeksville.mesh"; option optimize_for = LITE_RUNTIME; @@ -43,17 +24,6 @@ message Position { */ sfixed32 longitude_i = 2; - /* - * TODO: REMOTE/INTEGRATE - * This is a special 'small' position update for lat/lon. - * It encodes a signed 16 bit latitude in the upper 2 bytes, and a signed longitude in the lower 16 bits. - * It is not currently implemented, but can be added in an automatically backwards compatible way later. - * Note: ONLY microlatlon OR latitude_i, longitude_i are populated in any particular position. - * A microdelta is always relative to the last received full position. - * - * fixed32 microlatlon = 3; - */ - /* * In meters above MSL (but see issue #359) */ @@ -195,7 +165,6 @@ message Position { /* * Ground speed in m/s and True North TRACK in 1/100 degrees - * * Clarification of terms: * - "track" is the direction of motion (measured in horizontal plane) * - "heading" is where the fuselage points (measured in horizontal plane) @@ -456,24 +425,20 @@ enum Team { * Broadcast when a newly powered mesh node wants to find a node num it can use * Sent from the phone over bluetooth to set the user id for the owner of this node. * Also sent from nodes to each other when a new node signs on (so all clients can have this info) - * * The algorithm is as follows: * when a node starts up, it broadcasts their user and the normal flow is for all * other nodes to reply with their User as well (so the new node can build its nodedb) * If a node ever receives a User (not just the first broadcast) message where * the sender node number equals our node number, that indicates a collision has * occurred and the following steps should happen: - * * If the receiving node (that was already in the mesh)'s macaddr is LOWER than the * new User who just tried to sign in: it gets to keep its nodenum. * We send a broadcast message of OUR User (we use a broadcast so that the other node can * receive our message, considering we have the same id - it also serves to let * observers correct their nodedb) - this case is rare so it should be okay. - * * If any node receives a User where the macaddr is GTE than their local macaddr, * they have been vetoed and should pick a new random nodenum (filtering against * whatever it knows about the nodedb) and rebroadcast their User. - * * A few nodenums are reserved and will never be requested: * 0xff - broadcast * 0 through 3 - for future use @@ -760,11 +725,8 @@ message MeshPacket { * This field is never sent over the air, it is only used internally inside of a local device node. * API clients (either on the local node or connected directly to the node) * can set this parameter if necessary. - * * (values must be <= 127 to keep protobuf field to one byte in size. - * * Detailed background on this field: - * * I noticed a funny side effect of lora being so slow: Usually when making * a protocol there isn’t much need to use message priority to change the order * of transmission (because interfaces are fairly fast). @@ -773,7 +735,6 @@ message MeshPacket { * In the case of meshtastic that means we want to send protocol acks as soon as possible * (to prevent unneeded retransmissions), we want routing messages to be sent next, * then messages marked as reliable and finally ‘background’ packets like periodic position updates. - * * So I bit the bullet and implemented a new (internal - not sent over the air) * field in MeshPacket called ‘priority’. * And the transmission queue in the router object is now a priority queue. @@ -976,16 +937,12 @@ enum Constants { /* * The bluetooth to device link: - * * Old BTLE protocol docs from TODO, merge in above and make real docs... - * * use protocol buffers, and NanoPB - * * messages from device to phone: * POSITION_UPDATE (..., time) * TEXT_RECEIVED(from, text, time) * OPAQUE_RECEIVED(from, payload, time) (for signal messages or other applications) - * * messages from phone to device: * SET_MYID(id, human readable long, human readable short) (send down the unique ID * string used for this node, a human readable string shown for that id, and a very @@ -994,7 +951,6 @@ enum Constants { * nodes() (returns list of nodes, with full info, last time seen, loc, battery * level etc) SET_CONFIG (switches device to a new set of radio params and * preshared key, drops all existing nodes, force our node to rejoin this new group) - * * Full information about a node on the mesh */ message NodeInfo { @@ -1060,7 +1016,6 @@ message NodeInfo { /* * Error codes for critical errors - * * The device might report these fault codes on the screen. * If you encounter a fault code, please post on the meshtastic.discourse.group * and we'll try to help. @@ -1243,7 +1198,6 @@ message MyNodeInfo { /* * Debug output from the device. - * * To minimize the size of records inside the device code, if a time/source/level is not set * on the message it is assumed to be a continuation of the previously sent message. * This allows the device code to use fixed maxlen 64 byte strings for messages, diff --git a/notused/future.proto b/notused/future.proto index e33abaa..902b0d8 100644 --- a/notused/future.proto +++ b/notused/future.proto @@ -28,7 +28,6 @@ message ManufacturingData { /* * This code is written during manfacturing time and allows users to confirm that * the initial manufacturing tests succeeded. - * * 0 means no test performed. * 1 means all tests passed * negative numbers indicate particular error codes diff --git a/portnums.proto b/portnums.proto index b40db86..8b37707 100644 --- a/portnums.proto +++ b/portnums.proto @@ -8,19 +8,14 @@ option go_package = "github.com/meshtastic/gomeshproto"; /* * For any new 'apps' that run on the device or via sister apps on phones/PCs they should pick and use a * unique 'portnum' for their application. - * * If you are making a new app using meshtastic, please send in a pull request to add your 'portnum' to this * master table. * PortNums should be assigned in the following range: - * * 0-63 Core Meshtastic use, do not use for third party apps * 64-127 Registered 3rd party apps, send in a pull request that adds a new entry to portnums.proto to register your application * 256-511 Use one of these portnums for your private applications that you don't want to register publically - * * All other values are reserved. - * * Note: This was formerly a Type enum named 'typ' with the same id # - * * We have change to this 'portnum' based scheme for specifying app handlers for particular payloads. * This change is backwards compatible by treating the legacy OPAQUE/CLEAR_TEXT values identically. */ diff --git a/radioconfig.proto b/radioconfig.proto index 5c13e4e..ce2bbd3 100644 --- a/radioconfig.proto +++ b/radioconfig.proto @@ -1,23 +1,4 @@ syntax = "proto3"; -/* - * Meshtastic protobufs - * - * For more information on protobufs (and tools to use them with the language of your choice) see - * https://developers.google.com/protocol-buffers/docs/proto3 - * - * We are not placing any of these defs inside a package, because if you do the - * resulting nanopb version is super verbose package mesh. - * - * Protobuf build instructions: - * - * To build java classes for reading writing: - * protoc -I=. --java_out /tmp mesh.proto - * - * To generate Nanopb c code: - * /home/kevinh/packages/nanopb-0.4.0-linux-x86/generator-bin/protoc --nanopb_out=/tmp -I=app/src/main/proto mesh.proto - * - * Nanopb binaries available here: https://jpa.kapsi.fi/nanopb/download/ use nanopb 0.4.0 - */ option java_package = "com.geeksville.mesh"; option java_outer_classname = "RadioConfigProtos"; @@ -26,10 +7,8 @@ option go_package = "github.com/meshtastic/gomeshproto"; /* * The frequency/regulatory region the user has selected. - * * Note: In 1.0 builds (which must still be supported by the android app for a * long time) this field will be unpopulated. - * * If firmware is ever upgraded from an old 1.0ish build, the old * MyNodeInfo.region string will be used to set UserPreferences.region and the * old value will be no longer set. @@ -106,7 +85,6 @@ enum RegionCode { * Defines the device's role on the Mesh network * unset * Behave normally. - * * Router * Functions as a router */ @@ -263,7 +241,6 @@ enum GpsCoordinateFormat { * Bit field of boolean configuration options, indicating which optional * fields to include when assembling POSITION messages * Longitude and latitude are always included (also time if GPS-synced) - * * NOTE: the more fields are included, the larger the message will be - * leading to longer airtime and a higher risk of packet loss */ @@ -396,7 +373,6 @@ message RadioConfig { /* * If we miss this many owner messages from a node, we declare the node * offline (defaults to 3 - to allow for some lost packets) (FIXME not yet used) - * * uint32 num_missed_to_fail = 3; TODO: REMOVE/INTEGRATE */ @@ -862,13 +838,11 @@ message RadioConfig { /* * If non-zero, the device will fully power off this many seconds after external power is removed. - * */ uint32 on_battery_shutdown_after_secs = 153; /* * Overrides HOPS_RELIABLE and sets the maximum number of hops. This can't be greater than 7. - * */ uint32 hop_limit = 154; diff --git a/remote_hardware.proto b/remote_hardware.proto index 654678c..e411fcf 100644 --- a/remote_hardware.proto +++ b/remote_hardware.proto @@ -8,12 +8,9 @@ option go_package = "github.com/meshtastic/gomeshproto"; /* * An example app to show off the module system. This message is used for * REMOTE_HARDWARE_APP PortNums. - * * Also provides easy remote access to any GPIO. - * * In the future other remote hardware operations can be added based on user interest * (i.e. serial output, spi/i2c input/output). - * * FIXME - currently this feature is turned on by default which is dangerous * because no security yet (beyond the channel mechanism). * It should be off by default and then protected based on some TBD mechanism