diff --git a/meshtastic/admin.options b/meshtastic/admin.options index 4804d891..022c4fd0 100644 --- a/meshtastic/admin.options +++ b/meshtastic/admin.options @@ -1,5 +1,7 @@ *AdminMessage.payload_variant anonymous_oneof:true +*AdminMessage.session_passkey max_size:8 + *AdminMessage.set_canned_message_module_messages max_size:201 *AdminMessage.get_canned_message_module_messages_response max_size:201 *AdminMessage.delete_file_request max_size:201 diff --git a/meshtastic/admin.proto b/meshtastic/admin.proto index 12fe0c74..37553d24 100644 --- a/meshtastic/admin.proto +++ b/meshtastic/admin.proto @@ -20,6 +20,14 @@ option swift_prefix = ""; * (Prior to 1.2 these operations were done via special ToRadio operations) */ message AdminMessage { + + /* + * The node generates this key and sends it with any get_x_response packets. + * The client MUST include the same key with any set_x commands. Key expires after 300 seconds. + * Prevents replay attacks for admin messages. + */ + bytes session_passkey = 101; + /* * TODO: REPLACE */ @@ -58,6 +66,11 @@ message AdminMessage { * TODO: REPLACE */ BLUETOOTH_CONFIG = 6; + + /* + * TODO: REPLACE + */ + SECURITY_CONFIG = 7; } /* @@ -305,6 +318,12 @@ message AdminMessage { */ bool remove_fixed_position = 42; + /* + * Set time only on the node + * Convenience method to set the time on the node (as Net quality) without any other position data + */ + fixed32 set_time_only = 43; + /* * Begins an edit transaction for config, module config, owner, and channel settings changes * This will delay the standard *implicit* save to the file system and subsequent reboot behavior until committed (commit_edit_settings) 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..47900e66 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 @@ -825,8 +828,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 +856,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; } /* @@ -1006,8 +1017,56 @@ message Config { /* * Enables device (serial style logs) over Bluetooth + * Moved to SecurityConfig + */ + bool device_logging_enabled = 4[deprecated = true]; + } + + message SecurityConfig { + + /* + * The public key of the user's device. + * 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. + * Used to create a shared key with a remote device. + */ + bytes private_key = 2; + + /* + * 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 via admin messages + * Device is managed by a mesh administrator. + */ + bool is_managed = 4; + + /* + * 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). + * Output live debug logging over serial. + */ + bool debug_log_api_enabled = 6; + + /* + * Enables device (serial style logs) over Bluetooth + */ + bool bluetooth_logging_enabled = 7; + + /* + * Allow incoming device control over the insecure legacy admin channel. */ - bool device_logging_enabled = 4; + bool admin_channel_enabled = 8; } /* @@ -1021,5 +1080,6 @@ message Config { DisplayConfig display = 5; LoRaConfig lora = 6; BluetoothConfig bluetooth = 7; + SecurityConfig security = 8; } } diff --git a/meshtastic/deviceonly.options b/meshtastic/deviceonly.options index e9477a04..6f533177 100644 --- a/meshtastic/deviceonly.options +++ b/meshtastic/deviceonly.options @@ -14,3 +14,8 @@ *NodeInfoLite.channel int_size:8 *NodeInfoLite.hops_away int_size:8 + +*UserLite.long_name max_size:40 +*UserLite.short_name max_size:5 +*UserLite.public_key max_size:32 # public key +*UserLite.macaddr max_size:6 fixed_length:true diff --git a/meshtastic/deviceonly.proto b/meshtastic/deviceonly.proto index 9c700dbb..b3fb4407 100644 --- a/meshtastic/deviceonly.proto +++ b/meshtastic/deviceonly.proto @@ -6,6 +6,7 @@ import "meshtastic/channel.proto"; import "meshtastic/localonly.proto"; import "meshtastic/mesh.proto"; import "meshtastic/telemetry.proto"; +import "meshtastic/config.proto"; import "nanopb.proto"; option csharp_namespace = "Meshtastic.Protobufs"; @@ -51,6 +52,50 @@ message PositionLite { Position.LocSource location_source = 5; } +message UserLite { + /* + * This is the addr of the radio. + */ + bytes macaddr = 1 [deprecated = true]; + + /* + * A full name for this user, i.e. "Kevin Hester" + */ + string long_name = 2; + + /* + * A VERY short name, ideally two characters. + * Suitable for a tiny OLED screen + */ + string short_name = 3; + + /* + * TBEAM, HELTEC, etc... + * Starting in 1.2.11 moved to hw_model enum in the NodeInfo object. + * Apps will still need the string here for older builds + * (so OTA update can find the right image), but if the enum is available it will be used instead. + */ + HardwareModel hw_model = 4; + + /* + * In some regions Ham radio operators have different bandwidth limitations than others. + * If this user is a licensed operator, set this flag. + * Also, "long_name" should be their licence number. + */ + bool is_licensed = 5; + + /* + * Indicates that the user's role in the mesh + */ + Config.DeviceConfig.Role role = 6; + + /* + * 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 = 7; +} + message NodeInfoLite { /* * The node number @@ -60,7 +105,7 @@ message NodeInfoLite { /* * The user info for this node */ - User user = 2; + UserLite user = 2; /* * This position data. Note: before 1.2.14 we would also store the last time we've heard from this node in position.time, that is no longer true. 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 { diff --git a/meshtastic/mesh.options b/meshtastic/mesh.options index 7075e2da..9730a6e8 100644 --- a/meshtastic/mesh.options +++ b/meshtastic/mesh.options @@ -3,6 +3,7 @@ *macaddr max_size:6 fixed_length:true # macaddrs *id max_size:16 # node id strings +*public_key max_size:32 # public key *User.long_name max_size:40 *User.short_name max_size:5 @@ -45,6 +46,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 7d070668..6679c73e 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) @@ -681,6 +681,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; } /* @@ -763,6 +769,16 @@ message Routing { * (i.e you did not send the request on the required bound channel) */ NOT_AUTHORIZED = 33; + + /* + * The client specified a PKI transport, but the node was unable to send the packet using PKI (and did not send the message at all) + */ + PKI_FAILED = 34; + + /* + * The receiving node does not have a Public Key to decode with + */ + PKI_UNKNOWN_PUBKEY = 35; } oneof variant { @@ -853,12 +869,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) @@ -1121,6 +1137,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; } /* @@ -1524,9 +1550,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 */ 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.options b/meshtastic/telemetry.options index 72aba927..073412ac 100644 --- a/meshtastic/telemetry.options +++ b/meshtastic/telemetry.options @@ -2,4 +2,7 @@ # https://jpa.kapsi.fi/nanopb/docs/reference.html#proto-file-options *EnvironmentMetrics.iaq int_size:16 -*EnvironmentMetrics.wind_direction int_size:16 \ No newline at end of file +*EnvironmentMetrics.wind_direction int_size:16 + +*LocalStats.num_online_nodes int_size:16 +*LocalStats.num_total_nodes int_size:16 diff --git a/meshtastic/telemetry.proto b/meshtastic/telemetry.proto index 98404cf4..6ca8db30 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,105 @@ 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; +} + +/* + * Local device mesh statistics + */ +message LocalStats { + /* + * How long the device has been running since the last reboot (in seconds) + */ + uint32 uptime_seconds = 1; + /* + * Utilization for the current channel, including well formed TX, RX and malformed RX (aka noise). + */ + float channel_utilization = 2; + /* + * Percent of airtime for transmission used within the last hour. + */ + float air_util_tx = 3; + + /* + * Number of packets sent + */ + uint32 num_packets_tx = 4; + + /* + * Number of packets received good + */ + uint32 num_packets_rx = 5; + + /* + * Number of packets received that are malformed or violate the protocol + */ + uint32 num_packets_rx_bad = 6; + + /* + * Number of nodes online (in the past 2 hours) + */ + uint32 num_online_nodes = 7; + + /* + * Number of nodes total + */ + uint32 num_total_nodes = 8; } /* @@ -259,6 +302,11 @@ message Telemetry { * Power Metrics */ PowerMetrics power_metrics = 5; + + /* + * Local device mesh statistics + */ + LocalStats local_stats = 6; } }