From b1e1a54330d1a7f74f097dbf27cdba9cfb739473 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Mon, 14 Dec 2020 20:49:25 +0800 Subject: [PATCH 01/25] add concept of very short ChannelSettings for common channels --- mesh.proto | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/mesh.proto b/mesh.proto index 46ba2c9..1183a7f 100644 --- a/mesh.proto +++ b/mesh.proto @@ -355,15 +355,15 @@ message ChannelSettings { // < on. Slow+long range } - /// Note: This is the 'old' mechanism for specifying channel parameters. - /// Either modem_config or bandwidth/spreading/coding will be specified - NOT - /// BOTH. As a heuristic: If bandwidth is specified, do not use modem_config. - /// Because protobufs take ZERO space when the value is zero this works out - /// nicely. - /// This value is replaced by bandwidth/spread_factor/coding_rate. If you'd - /// like to experiment with other options add them to MeshRadio.cpp in the - /// device code. - ModemConfig modem_config = 3 [deprecated = true]; + // Note: This is the 'old' mechanism for specifying channel parameters. + // Either modem_config or bandwidth/spreading/coding will be specified - NOT + // BOTH. As a heuristic: If bandwidth is specified, do not use modem_config. + // Because protobufs take ZERO space when the value is zero this works out + // nicely. + // This value is replaced by bandwidth/spread_factor/coding_rate. If you'd + // like to experiment with other options add them to MeshRadio.cpp in the + // device code. + ModemConfig modem_config = 3; /** Bandwidth in MHz @@ -402,12 +402,20 @@ message ChannelSettings { */ uint32 channel_num = 9; - /// A simple preshared key for now for crypto. Must be either 0 bytes (no - /// crypto), 16 bytes (AES128), or 32 bytes (AES256) + // A simple preshared key for now for crypto. Must be either 0 bytes (no + // crypto), 16 bytes (AES128), or 32 bytes (AES256) + // A special shorthand is used for 1 byte long psks. These psks should be treated as only minimally secure, + // because they are listed in this source code. Those bytes are mapped using the following scheme: + // 0 = No crypto + // 1 = The special default channel key: {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59, 0xf0, 0xbc, 0xff, 0xab, 0xcf, 0x4e, 0x69, 0xbf} + // 2 through 10 = The default channel key, except with 1 through 9 added to the last byte bytes psk = 4; - /// A SHORT name that will be packed into the URL. Less than 12 bytes. - /// Something for end users to call the channel + // A SHORT name that will be packed into the URL. Less than 12 bytes. + // Something for end users to call the channel + // If this is the empty string it is assumed that this channel is the special (minimially secure) "Default" + // channel. In user interfaces it should be rendered as a local language translation of "Default". For channel_num + // hashing empty string will be treated as "Default" string name = 5; } From 7b1c0578586c154b94b30f60adc5aee607a811ab Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Tue, 15 Dec 2020 13:12:44 +0800 Subject: [PATCH 02/25] Simpilify channel naming for various channel speeds --- mesh.proto | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mesh.proto b/mesh.proto index 1183a7f..828a831 100644 --- a/mesh.proto +++ b/mesh.proto @@ -343,16 +343,21 @@ message ChannelSettings { */ enum ModemConfig { Bw125Cr45Sf128 = 0 ; // < Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC - // < on. Default medium range + // < on. Medium range + // The english default channel name for this setting is "MediumRange" Bw500Cr45Sf128 = 1; // < Bw = 500 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC // < on. Fast+short range + // The english default channel name for this setting is "Fast" Bw31_25Cr48Sf512 = 2; // < Bw = 31.25 kHz, Cr = 4/8, Sf = 512chips/symbol, ///< CRC on. Slow+long range + // The english default channel name for this setting is "LongAlt" Bw125Cr48Sf4096 = 3; // < Bw = 125 kHz, Cr = 4/8, Sf = 4096chips/symbol, CRC - // < on. Slow+long range + // < on. Slow+long range **This is the default channel settting** + // The english default channel name for this setting is "LongRange" + // If old applications try to set the name to "Default" we will change it to "LongRange" } // Note: This is the 'old' mechanism for specifying channel parameters. @@ -414,8 +419,10 @@ message ChannelSettings { // A SHORT name that will be packed into the URL. Less than 12 bytes. // Something for end users to call the channel // If this is the empty string it is assumed that this channel is the special (minimially secure) "Default" - // channel. In user interfaces it should be rendered as a local language translation of "Default". For channel_num - // hashing empty string will be treated as "Default" + // channel. In user interfaces it should be rendered as a local language translation of "X". For channel_num + // hashing empty string will be treated as "X". + // Where "X" is selected based on the english words listed above for ModemConfig + // string name = 5; } From 5f580041beeb593d48eabacd2b959df04558c383 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Tue, 15 Dec 2020 13:13:50 +0800 Subject: [PATCH 03/25] update docs --- docs/docs.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/docs.md b/docs/docs.md index f3c61a4..6fe6ca0 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -90,13 +90,13 @@ Y is a lower case letter from a-z that represents the channel 'speed' se | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | tx_power | [int32](#int32) | | If zero then, use default max legal continuous power (ie. something that won't burn out the radio hardware) In most cases you should use zero here. | -| modem_config | [ChannelSettings.ModemConfig](#ChannelSettings.ModemConfig) | | Note: This is the 'old' mechanism for specifying channel parameters. / Either modem_config or bandwidth/spreading/coding will be specified - NOT / BOTH. As a heuristic: If bandwidth is specified, do not use modem_config. / Because protobufs take ZERO space when the value is zero this works out / nicely. / This value is replaced by bandwidth/spread_factor/coding_rate. If you'd / like to experiment with other options add them to MeshRadio.cpp in the / device code. | +| modem_config | [ChannelSettings.ModemConfig](#ChannelSettings.ModemConfig) | | Note: This is the 'old' mechanism for specifying channel parameters. Either modem_config or bandwidth/spreading/coding will be specified - NOT BOTH. As a heuristic: If bandwidth is specified, do not use modem_config. Because protobufs take ZERO space when the value is zero this works out nicely. This value is replaced by bandwidth/spread_factor/coding_rate. If you'd like to experiment with other options add them to MeshRadio.cpp in the device code. | | bandwidth | [uint32](#uint32) | | Bandwidth in MHz Certain bandwidth numbers are 'special' and will be converted to the appropriate floating point value: 31 -> 31.25MHz | | spread_factor | [uint32](#uint32) | | A number from 7 to 12. Indicates number of chirps per symbol as 1<<spread_factor. | | coding_rate | [uint32](#uint32) | | The denominator of the coding rate. ie for 4/8, the value is 8. 5/8 the value is 5. | | channel_num | [uint32](#uint32) | | A channel number between 1 and 13 (or whatever the max is in the current region). If ZERO then the rule is "use the old channel name hash based algoritm to derive the channel number") If using the hash algorithm the channel number will be: hash(channel_name) % NUM_CHANNELS (Where num channels depends on the regulatory region). NUM_CHANNELS_US is 13, for other values see MeshRadio.h in the device code. hash a string into an integer - djb2 by Dan Bernstein. - http://www.cse.yorku.ca/~oz/hash.html unsigned long hash(char *str) { unsigned long hash = 5381; int c; while ((c = *str++) != 0) hash = ((hash << 5) + hash) + (unsigned char) c; return hash; } | -| psk | [bytes](#bytes) | | A simple preshared key for now for crypto. Must be either 0 bytes (no / crypto), 16 bytes (AES128), or 32 bytes (AES256) | -| name | [string](#string) | | A SHORT name that will be packed into the URL. Less than 12 bytes. / Something for end users to call the channel | +| psk | [bytes](#bytes) | | A simple preshared key for now for crypto. Must be either 0 bytes (no crypto), 16 bytes (AES128), or 32 bytes (AES256) A special shorthand is used for 1 byte long psks. These psks should be treated as only minimally secure, because they are listed in this source code. Those bytes are mapped using the following scheme: 0 = No crypto 1 = The special default channel key: {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59, 0xf0, 0xbc, 0xff, 0xab, 0xcf, 0x4e, 0x69, 0xbf} 2 through 10 = The default channel key, except with 1 through 9 added to the last byte | +| name | [string](#string) | | A SHORT name that will be packed into the URL. Less than 12 bytes. Something for end users to call the channel If this is the empty string it is assumed that this channel is the special (minimially secure) "Default" channel. In user interfaces it should be rendered as a local language translation of "X". For channel_num hashing empty string will be treated as "X". Where "X" is selected based on the english words listed above for ModemConfig | @@ -591,6 +591,7 @@ This change is backwards compatible by treating the legacy OPAQUE/CLEAR_TEXT val | REMOTE_HARDWARE_APP | 2 | Reserved for built-in GPIO/example app. See remote_hardware.proto/HardwareMessage for details on the message sent/received to this port number | | POSITION_APP | 3 | The built-in position messaging app. See Position for details on the message sent to this port number. | | NODEINFO_APP | 4 | The built-in user info app. See User for details on the message sent to this port number. | +| REPLY_APP | 32 | Provides a 'ping' service that replies to any packet it receives. Also this serves as a small example plugin. | | PRIVATE_APP | 256 | Private applications should use portnums >= 256. To simplify initial development and testing you can use "PRIVATE_APP" in your code without needing to rebuild protobuf files (via bin/regin_protos.sh) | | IP_TUNNEL_APP | 1024 | 1024-66559 Are reserved for use by IP tunneling (see FIXME for more information) | From e0df97118b3dc8105c9c8dbd59e9bb8cd859b1bb Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Tue, 15 Dec 2020 13:38:28 +0800 Subject: [PATCH 04/25] changes for human names for channels --- mesh.proto | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mesh.proto b/mesh.proto index 828a831..0dc8e24 100644 --- a/mesh.proto +++ b/mesh.proto @@ -344,11 +344,11 @@ message ChannelSettings { enum ModemConfig { Bw125Cr45Sf128 = 0 ; // < Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC // < on. Medium range - // The english default channel name for this setting is "MediumRange" + // The english default channel name for this setting is "Medium" Bw500Cr45Sf128 = 1; // < Bw = 500 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC // < on. Fast+short range - // The english default channel name for this setting is "Fast" + // The english default channel name for this setting is "ShortFast" Bw31_25Cr48Sf512 = 2; // < Bw = 31.25 kHz, Cr = 4/8, Sf = 512chips/symbol, ///< CRC on. Slow+long range @@ -356,8 +356,8 @@ message ChannelSettings { Bw125Cr48Sf4096 = 3; // < Bw = 125 kHz, Cr = 4/8, Sf = 4096chips/symbol, CRC // < on. Slow+long range **This is the default channel settting** - // The english default channel name for this setting is "LongRange" - // If old applications try to set the name to "Default" we will change it to "LongRange" + // The english default channel name for this setting is "LongSlow" + // If old applications try to set the name to "Default" we will change it to "LongSlow" } // Note: This is the 'old' mechanism for specifying channel parameters. From 3d0bcc2afa6fb161bd2d0c7c2e76083c3946ed65 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Thu, 17 Dec 2020 10:31:40 +0800 Subject: [PATCH 05/25] begin support for multiple simultaneous channels --- docs/docs.md | 6 ++++-- mesh.options | 2 ++ mesh.proto | 15 +++++++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/docs/docs.md b/docs/docs.md index 6fe6ca0..f4be4cd 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -201,6 +201,7 @@ MeshPacket). | ----- | ---- | ----- | ----------- | | from | [uint32](#uint32) | | The sending node number. Note: Our crypto implementation uses this field as well. See docs/software/crypto.md for details. FIXME - really should be fixed32 instead, this encoding only hurts the ble link though. | | to | [uint32](#uint32) | | The (immediate) destination for this packet. If we are using routing, the final destination will be in payload.dest FIXME - really should be fixed32 instead, this encoding only hurts the ble link though. | +| channel_index | [uint32](#uint32) | | If set, this indicates the index in the secondary_channels table that this packet was sent/received on. If unset, packet was on the primary channel. | | decoded | [SubPacket](#SubPacket) | | | | encrypted | [bytes](#bytes) | | | | id | [uint32](#uint32) | | A unique ID for this packet. Always 0 for no-ack packets or non broadcast packets (and therefore take zero bytes of space). Otherwise a unique ID for this packet. Useful for flooding algorithms. ID only needs to be unique on a _per sender_ basis. And it only needs to be unique for a few minutes (long enough to last for the length of any ACK or the completion of a mesh broadcast flood). Note: Our crypto implementation uses this id as well. See docs/software/crypto.md for details. FIXME - really should be fixed32 instead, this encoding only hurts the ble link though. | @@ -296,6 +297,7 @@ set for behavior of their node | ----- | ---- | ----- | ----------- | | preferences | [RadioConfig.UserPreferences](#RadioConfig.UserPreferences) | | | | channel_settings | [ChannelSettings](#ChannelSettings) | | | +| secondary_channels | [ChannelSettings](#ChannelSettings) | repeated | Secondary channels are only used for encryption/decryption/authentication purposes. Their radio settings (freq etc) are ignored, only psk is used. | @@ -310,7 +312,7 @@ see sw-design.md for more information on these preferences | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| position_broadcast_secs | [uint32](#uint32) | | We should send our position this often (but only if it has changed significantly) | +| position_broadcast_secs | [uint32](#uint32) | | We should send our position this often (but only if it has changed significantly). Defaults to 15 minutes | | send_owner_interval | [uint32](#uint32) | | Send our owner info at least this often (also we always send once at boot - to rejoin the mesh) | | num_missed_to_fail | [uint32](#uint32) | | If we miss this many owner messages from a node, we declare the node / offline (defaults to 3 - to allow for some lost packets) | | wait_bluetooth_secs | [uint32](#uint32) | | 0 for default of 1 minute | @@ -334,7 +336,7 @@ The lat/lon/alt can be set by an internal GPS or with the help of the app. | | debug_log_enabled | [bool](#bool) | | 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. | | location_share | [LocationSharing](#LocationSharing) | | | | gps_operation | [GpsOperation](#GpsOperation) | | | -| gps_update_interval | [uint32](#uint32) | | How often should we try to get GPS position (in seconds) when we are in GpsOpMobile mode? or zero for the default of once every 30 seconds or a very large value (maxint) to update only once at boot. | +| gps_update_interval | [uint32](#uint32) | | How often should we try to get GPS position (in seconds) when we are in GpsOpMobile mode? or zero for the default of once every 120 seconds or a very large value (maxint) to update only once at boot. | | gps_attempt_time | [uint32](#uint32) | | How long should we try to get our position during each gps_update_interval attempt? (in seconds) Or if zero, use the default of 30 seconds. If we don't get a new gps fix in that time, the gps will be put into sleep until the next gps_update_rate window. | | ignore_incoming | [uint32](#uint32) | repeated | For testing it is useful sometimes to force a node to never listen to particular other nodes (simulating radio out of range). All nodenums listed in ignore_incoming will have packets they send droped on receive (by router.cpp) | diff --git a/mesh.options b/mesh.options index d8fc4d0..caf978a 100644 --- a/mesh.options +++ b/mesh.options @@ -27,6 +27,8 @@ *ChannelSettings.psk max_size:32 *ChannelSettings.name max_size:12 +*RadioConfig.secondary_channels max_count:4 + *MyNodeInfo.firmware_version max_size:12 *MyNodeInfo.hw_model max_size:16 *MyNodeInfo.region max_size:12 diff --git a/mesh.proto b/mesh.proto index 0dc8e24..0e217b2 100644 --- a/mesh.proto +++ b/mesh.proto @@ -229,6 +229,12 @@ message MeshPacket { */ uint32 to = 2; + /** + If set, this indicates the index in the secondary_channels table that this packet + was sent/received on. If unset, packet was on the primary channel. + */ + uint32 channel_index = 4; + /** Internally to the mesh radios we will route SubPackets encrypted per docs/software/crypto.md. However, when a particular node has the correct @@ -499,7 +505,7 @@ message RadioConfig { /// see sw-design.md for more information on these preferences message UserPreferences { // We should send our position this often (but only if it has changed - // significantly) + // significantly). Defaults to 15 minutes uint32 position_broadcast_secs = 1; // Send our owner info at least this often (also we always send once at boot @@ -569,7 +575,7 @@ message RadioConfig { GpsOperation gps_operation = 33; /** How often should we try to get GPS position (in seconds) when we are in GpsOpMobile mode? - or zero for the default of once every 30 seconds + or zero for the default of once every 120 seconds or a very large value (maxint) to update only once at boot. */ uint32 gps_update_interval = 34; @@ -600,6 +606,11 @@ message RadioConfig { UserPreferences preferences = 1; ChannelSettings channel_settings = 2; + + /** Secondary channels are only used for encryption/decryption/authentication purposes. Their radio settings (freq etc) + are ignored, only psk is used. + */ + repeated ChannelSettings secondary_channels = 3; } /** From 75078afe43934f4ce15ef86ebc6950658a170145 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Thu, 17 Dec 2020 10:52:31 +0800 Subject: [PATCH 06/25] move secondary_channels out of radioconfig --- docs/docs.md | 5 ++++- mesh.options | 4 ++-- mesh.proto | 15 ++++++++++----- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/docs/docs.md b/docs/docs.md index f4be4cd..60e03e3 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -156,6 +156,9 @@ the receive queue and use the preferences store for the other stuff | rx_text_message | [MeshPacket](#MeshPacket) | | We keep the last received text message (only) stored in the device flash, so we can show it on the screen. Might be null | | no_save | [bool](#bool) | | Used only during development. Indicates developer is testing and changes should never be saved to flash. | | did_gps_reset | [bool](#bool) | | Some GPSes seem to have bogus settings from the factory, so we always do one factory reset | +| secondary_channels | [ChannelSettings](#ChannelSettings) | repeated | Secondary channels are only used for encryption/decryption/authentication purposes. Their radio settings (freq etc) are ignored, only psk is used. + +Note: this is not kept inside of RadioConfig because that would make ToRadio/FromRadio worse case > 512 bytes (to big for BLE) | @@ -182,6 +185,7 @@ FIFO will be populated. | debug_string | [DebugString](#DebugString) | | set to send debug console output over our protobuf stream | | config_complete_id | [uint32](#uint32) | | sent as true once the device has finished sending all of the responses to want_config recipient should check if this ID matches our original request nonce, if not, it means your config responses haven't started yet | | rebooted | [bool](#bool) | | Sent to tell clients the radio has just rebooted. Set to true if present. Not used on all transports, currently just used for the serial console. | +| secondary_channel | [ChannelSettings](#ChannelSettings) | | One of the secondary channels, they are all sent during config download | @@ -297,7 +301,6 @@ set for behavior of their node | ----- | ---- | ----- | ----------- | | preferences | [RadioConfig.UserPreferences](#RadioConfig.UserPreferences) | | | | channel_settings | [ChannelSettings](#ChannelSettings) | | | -| secondary_channels | [ChannelSettings](#ChannelSettings) | repeated | Secondary channels are only used for encryption/decryption/authentication purposes. Their radio settings (freq etc) are ignored, only psk is used. | diff --git a/mesh.options b/mesh.options index caf978a..3c09977 100644 --- a/mesh.options +++ b/mesh.options @@ -13,6 +13,8 @@ # FIXME - max_count is actually 32 but we save/load this as one long string of preencoded MeshPacket bytes - not a big array in RAM *DeviceState.receive_queue max_count:1 +*DeviceState.secondary_channels max_count:4 + *RouteDiscovery.route max_count:8 # FIXME, max out based on total SubPacket size And do fragmentation and reassembly (for larger payloads) at the Android layer, not the esp32 layer. @@ -27,8 +29,6 @@ *ChannelSettings.psk max_size:32 *ChannelSettings.name max_size:12 -*RadioConfig.secondary_channels max_count:4 - *MyNodeInfo.firmware_version max_size:12 *MyNodeInfo.hw_model max_size:16 *MyNodeInfo.region max_size:12 diff --git a/mesh.proto b/mesh.proto index 0e217b2..581d81d 100644 --- a/mesh.proto +++ b/mesh.proto @@ -606,11 +606,6 @@ message RadioConfig { UserPreferences preferences = 1; ChannelSettings channel_settings = 2; - - /** Secondary channels are only used for encryption/decryption/authentication purposes. Their radio settings (freq etc) - are ignored, only psk is used. - */ - repeated ChannelSettings secondary_channels = 3; } /** @@ -801,6 +796,13 @@ message DeviceState { // Some GPSes seem to have bogus settings from the factory, so we always do // one factory reset bool did_gps_reset = 11; + + /** Secondary channels are only used for encryption/decryption/authentication purposes. Their radio settings (freq etc) + are ignored, only psk is used. + + Note: this is not kept inside of RadioConfig because that would make ToRadio/FromRadio worse case > 512 bytes (to big for BLE) + */ + repeated ChannelSettings secondary_channels = 12; } /// Debug output from the device @@ -847,6 +849,9 @@ message FromRadio { // present. Not used on all transports, currently just used for the serial // console. bool rebooted = 9; + + // One of the secondary channels, they are all sent during config download + ChannelSettings secondary_channel = 10; } } From f1cd4925291fd004a2a2e082b34b098f5f3abc10 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Mon, 21 Dec 2020 10:15:48 +0800 Subject: [PATCH 07/25] doc updates --- docs/docs.md | 26 ++++++++++++-------------- mesh.proto | 31 +++++++++++++++++++++---------- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/docs/docs.md b/docs/docs.md index 60e03e3..2d1674e 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -318,27 +318,25 @@ see sw-design.md for more information on these preferences | position_broadcast_secs | [uint32](#uint32) | | We should send our position this often (but only if it has changed significantly). Defaults to 15 minutes | | send_owner_interval | [uint32](#uint32) | | Send our owner info at least this often (also we always send once at boot - to rejoin the mesh) | | num_missed_to_fail | [uint32](#uint32) | | If we miss this many owner messages from a node, we declare the node / offline (defaults to 3 - to allow for some lost packets) | -| wait_bluetooth_secs | [uint32](#uint32) | | 0 for default of 1 minute | -| screen_on_secs | [uint32](#uint32) | | 0 for default of one minute | -| phone_timeout_secs | [uint32](#uint32) | | 0 for default of 15 minutes | -| phone_sds_timeout_sec | [uint32](#uint32) | | 0 for default of two hours, MAXUINT for disabled | -| mesh_sds_timeout_secs | [uint32](#uint32) | | 0 for default of two hours, MAXUINT for disabled | -| sds_secs | [uint32](#uint32) | | 0 for default of one year | -| ls_secs | [uint32](#uint32) | | 0 for default of 3600 | -| min_wake_secs | [uint32](#uint32) | | 0 for default of 10 seconds | +| wait_bluetooth_secs | [uint32](#uint32) | | Power management state machine option. See https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/power.md for details. 0 for default of 1 minute | +| screen_on_secs | [uint32](#uint32) | | Power management state machine option. See https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/power.md for details. 0 for default of one minute | +| phone_timeout_secs | [uint32](#uint32) | | Power management state machine option. See https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/power.md for details. 0 for default of 15 minutes | +| phone_sds_timeout_sec | [uint32](#uint32) | | Power management state machine option. See https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/power.md for details. 0 for default of two hours, MAXUINT for disabled | +| mesh_sds_timeout_secs | [uint32](#uint32) | | Power management state machine option. See https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/power.md for details. 0 for default of two hours, MAXUINT for disabled | +| sds_secs | [uint32](#uint32) | | Power management state machine option. See https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/power.md for details. 0 for default of one year | +| ls_secs | [uint32](#uint32) | | Power management state machine option. See https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/power.md for details. 0 for default of 3600 | +| min_wake_secs | [uint32](#uint32) | | Power management state machine option. See https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/power.md for details. 0 for default of 10 seconds | | wifi_ssid | [string](#string) | | If set, this node will try to join the specified wifi network and acquire an address via DHCP | | wifi_password | [string](#string) | | If set, will be use to authenticate to the named wifi | | wifi_ap_mode | [bool](#bool) | | If set, the node will operate as an AP (and DHCP server), otherwise it will be a station | | region | [RegionCode](#RegionCode) | | The region code for my radio (US, CN, EU433, etc...) | -| is_router | [bool](#bool) | | Are we operating as a router. Changes behavior in the following ways: FIXME | +| is_router | [bool](#bool) | | Are we operating as a router. Changes behavior in the following ways: The device will only sleep for critically low battery level (i.e. always tries to stay alive for the mesh) In the future routing decisions will preferentially route packets through nodes with this attribute (because assumed good line of sight) | | is_low_power | [bool](#bool) | | If set, we are powered from a low-current source (i.e. solar), so even if it looks like we have power flowing in we should try to minimize power consumption as much as possible. Often combined with is_router. | -| fixed_position | [bool](#bool) | | If set, this node is at a fixed position. We will generate GPS position updates at the regular interval, but use whatever the last lat/lon/alt we have for the node. - -The lat/lon/alt can be set by an internal GPS or with the help of the app. | +| fixed_position | [bool](#bool) | | If set, this node is at a fixed position. We will generate GPS position updates at the regular interval, but use whatever the last lat/lon/alt we have for the node. The lat/lon/alt can be set by an internal GPS or with the help of the app. | | factory_reset | [bool](#bool) | | This setting is never saved to disk, but if set, all device settings will be returned to factory defaults. (Region, serial number etc... will be preserved) | | debug_log_enabled | [bool](#bool) | | 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. | -| location_share | [LocationSharing](#LocationSharing) | | | -| gps_operation | [GpsOperation](#GpsOperation) | | | +| location_share | [LocationSharing](#LocationSharing) | | How our location is shared with other nodes (or the local phone) | +| gps_operation | [GpsOperation](#GpsOperation) | | How the GPS hardware in this unit is operated. Note: This is independent of how our location is shared with other devices. For that see LocationSharing | | gps_update_interval | [uint32](#uint32) | | How often should we try to get GPS position (in seconds) when we are in GpsOpMobile mode? or zero for the default of once every 120 seconds or a very large value (maxint) to update only once at boot. | | gps_attempt_time | [uint32](#uint32) | | How long should we try to get our position during each gps_update_interval attempt? (in seconds) Or if zero, use the default of 30 seconds. If we don't get a new gps fix in that time, the gps will be put into sleep until the next gps_update_rate window. | | ignore_incoming | [uint32](#uint32) | repeated | For testing it is useful sometimes to force a node to never listen to particular other nodes (simulating radio out of range). All nodenums listed in ignore_incoming will have packets they send droped on receive (by router.cpp) | diff --git a/mesh.proto b/mesh.proto index 581d81d..24a4624 100644 --- a/mesh.proto +++ b/mesh.proto @@ -516,20 +516,22 @@ message RadioConfig { /// offline (defaults to 3 - to allow for some lost packets) uint32 num_missed_to_fail = 3; - uint32 wait_bluetooth_secs = 4; // 0 for default of 1 minute - uint32 screen_on_secs = 5; // 0 for default of one minute - uint32 phone_timeout_secs = 6; // 0 for default of 15 minutes - uint32 phone_sds_timeout_sec = 7; // 0 for default of two hours, MAXUINT for disabled - uint32 mesh_sds_timeout_secs = 8; // 0 for default of two hours, MAXUINT for disabled - uint32 sds_secs = 9; // 0 for default of one year - uint32 ls_secs = 10; // 0 for default of 3600 - uint32 min_wake_secs = 11; // 0 for default of 10 seconds + uint32 wait_bluetooth_secs = 4; // Power management state machine option. See https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/power.md for details. 0 for default of 1 minute + uint32 screen_on_secs = 5; // Power management state machine option. See https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/power.md for details. 0 for default of one minute + uint32 phone_timeout_secs = 6; // Power management state machine option. See https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/power.md for details. 0 for default of 15 minutes + uint32 phone_sds_timeout_sec = 7; // Power management state machine option. See https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/power.md for details. 0 for default of two hours, MAXUINT for disabled + uint32 mesh_sds_timeout_secs = 8; // Power management state machine option. See https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/power.md for details. 0 for default of two hours, MAXUINT for disabled + uint32 sds_secs = 9; // Power management state machine option. See https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/power.md for details. 0 for default of one year + uint32 ls_secs = 10; // Power management state machine option. See https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/power.md for details. 0 for default of 3600 + uint32 min_wake_secs = 11; // Power management state machine option. See https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/power.md for details. 0 for default of 10 seconds /** If set, this node will try to join the specified wifi network and * acquire an address via DHCP */ string wifi_ssid = 12; + /** If set, will be use to authenticate to the named wifi */ string wifi_password = 13; + /** If set, the node will operate as an AP (and DHCP server), otherwise it * will be a station */ bool wifi_ap_mode = 14; @@ -539,7 +541,9 @@ message RadioConfig { /** Are we operating as a router. Changes behavior in the following ways: - FIXME + The device will only sleep for critically low battery level (i.e. always tries to stay alive for the mesh) + In the future routing decisions will preferentially route packets through nodes with this attribute (because assumed + good line of sight) */ bool is_router = 37; @@ -552,7 +556,6 @@ message RadioConfig { /** If set, this node is at a fixed position. We will generate GPS position updates at the regular interval, but use whatever the last lat/lon/alt we have for the node. - The lat/lon/alt can be set by an internal GPS or with the help of the app. */ bool fixed_position = 39; @@ -571,7 +574,15 @@ message RadioConfig { */ bool debug_log_enabled = 101; + /** + How our location is shared with other nodes (or the local phone) + */ LocationSharing location_share = 32; + + /** + How the GPS hardware in this unit is operated. + Note: This is independent of how our location is shared with other devices. For that see LocationSharing + */ GpsOperation gps_operation = 33; /** How often should we try to get GPS position (in seconds) when we are in GpsOpMobile mode? From 020ef9eea8129756a0b45be5a3900b0355be4451 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Mon, 21 Dec 2020 10:21:34 +0800 Subject: [PATCH 08/25] remove unused param --- docs/docs.md | 1 - mesh.proto | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/docs.md b/docs/docs.md index 2d1674e..cc03cbf 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -317,7 +317,6 @@ see sw-design.md for more information on these preferences | ----- | ---- | ----- | ----------- | | position_broadcast_secs | [uint32](#uint32) | | We should send our position this often (but only if it has changed significantly). Defaults to 15 minutes | | send_owner_interval | [uint32](#uint32) | | Send our owner info at least this often (also we always send once at boot - to rejoin the mesh) | -| num_missed_to_fail | [uint32](#uint32) | | If we miss this many owner messages from a node, we declare the node / offline (defaults to 3 - to allow for some lost packets) | | wait_bluetooth_secs | [uint32](#uint32) | | Power management state machine option. See https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/power.md for details. 0 for default of 1 minute | | screen_on_secs | [uint32](#uint32) | | Power management state machine option. See https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/power.md for details. 0 for default of one minute | | phone_timeout_secs | [uint32](#uint32) | | Power management state machine option. See https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/power.md for details. 0 for default of 15 minutes | diff --git a/mesh.proto b/mesh.proto index 24a4624..f1fef18 100644 --- a/mesh.proto +++ b/mesh.proto @@ -513,8 +513,8 @@ message RadioConfig { uint32 send_owner_interval = 2; /// If we miss this many owner messages from a node, we declare the node - /// offline (defaults to 3 - to allow for some lost packets) - uint32 num_missed_to_fail = 3; + /// offline (defaults to 3 - to allow for some lost packets) (FIXME not yet used) + // uint32 num_missed_to_fail = 3; uint32 wait_bluetooth_secs = 4; // Power management state machine option. See https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/power.md for details. 0 for default of 1 minute uint32 screen_on_secs = 5; // Power management state machine option. See https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/power.md for details. 0 for default of one minute From 3c06a5962b35f3959f17b9120802bf286dba01c7 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Mon, 21 Dec 2020 14:46:17 +0800 Subject: [PATCH 09/25] add doc note --- mesh.proto | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mesh.proto b/mesh.proto index f1fef18..f6772f5 100644 --- a/mesh.proto +++ b/mesh.proto @@ -549,7 +549,8 @@ message RadioConfig { /** If set, we are powered from a low-current source (i.e. solar), so even if it looks like we have power flowing in - we should try to minimize power consumption as much as possible. Often combined with is_router. + we should try to minimize power consumption as much as possible. YOU DO NOT NEED TO SET THIS IF YOU'VE + set is_router (it is implied in that case). */ bool is_low_power = 38; From 3473446418a4e83ff0ff4c7588101c2e1b29e604 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Wed, 23 Dec 2020 17:45:28 +0800 Subject: [PATCH 10/25] IP tunnel only needs one meshtastic portnum --- portnums.proto | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/portnums.proto b/portnums.proto index 964be66..422b6ca 100644 --- a/portnums.proto +++ b/portnums.proto @@ -15,7 +15,6 @@ option optimize_for = LITE_RUNTIME; 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 - 1024-66559 Are reserved for use by IP tunneling (see FIXME for more information) All other values are reserved. @@ -70,10 +69,10 @@ enum PortNum { */ REPLY_APP = 32; + /** Used for the python IP tunnel feature */ + IP_TUNNEL_APP = 33; + /** Private applications should use portnums >= 256. To simplify initial development and testing you can use "PRIVATE_APP" in your code without needing to rebuild protobuf files (via bin/regin_protos.sh) */ PRIVATE_APP = 256; - - /** 1024-66559 Are reserved for use by IP tunneling (see FIXME for more information) */ - IP_TUNNEL_APP = 1024; } \ No newline at end of file From e7ab73e2a9f74b67a0e57eb58fe59f4d22a9c706 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Sun, 27 Dec 2020 10:55:13 +0800 Subject: [PATCH 11/25] Clean up LogRecord --- docs/docs.md | 60 +++++++++++++++++++++++++++++++++++++--------------- mesh.options | 3 +++ mesh.proto | 33 +++++++++++++++++++++++++---- 3 files changed, 75 insertions(+), 21 deletions(-) diff --git a/docs/docs.md b/docs/docs.md index cc03cbf..51571fd 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -6,9 +6,9 @@ - [mesh.proto](#mesh.proto) - [ChannelSettings](#.ChannelSettings) - [Data](#.Data) - - [DebugString](#.DebugString) - [DeviceState](#.DeviceState) - [FromRadio](#.FromRadio) + - [LogRecord](#.LogRecord) - [MeshPacket](#.MeshPacket) - [MyNodeInfo](#.MyNodeInfo) - [NodeInfo](#.NodeInfo) @@ -24,6 +24,7 @@ - [Constants](#.Constants) - [GpsOperation](#.GpsOperation) - [LocationSharing](#.LocationSharing) + - [LogRecord.Level](#.LogRecord.Level) - [RegionCode](#.RegionCode) - [RouteError](#.RouteError) @@ -120,21 +121,6 @@ internally in the case of CLEAR_TEXT and CLEAR_READACK) - - -### DebugString -Debug output from the device - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| message | [string](#string) | | | - - - - - - ### DeviceState @@ -182,7 +168,7 @@ FIFO will be populated. | my_info | [MyNodeInfo](#MyNodeInfo) | | Tells the phone what our node number is, can be -1 if we've not yet joined a mesh. | | node_info | [NodeInfo](#NodeInfo) | | One packet is sent for each node in the on radio DB starts over with the first node in our DB | | radio | [RadioConfig](#RadioConfig) | | In rev1 this was the radio BLE characteristic | -| debug_string | [DebugString](#DebugString) | | set to send debug console output over our protobuf stream | +| log_record | [LogRecord](#LogRecord) | | set to send debug console output over our protobuf stream | | config_complete_id | [uint32](#uint32) | | sent as true once the device has finished sending all of the responses to want_config recipient should check if this ID matches our original request nonce, if not, it means your config responses haven't started yet | | rebooted | [bool](#bool) | | Sent to tell clients the radio has just rebooted. Set to true if present. Not used on all transports, currently just used for the serial console. | | secondary_channel | [ChannelSettings](#ChannelSettings) | | One of the secondary channels, they are all sent during config download | @@ -192,6 +178,29 @@ FIFO will be populated. + + +### LogRecord +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 contuinuation of the previously sent message. This allows +the device code to use fixed maxlen 64 byte strings for messages, and then extend as needed by +emitting multiple records. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| message | [string](#string) | | | +| time | [fixed32](#fixed32) | | Seconds since 1970 - or 0 for unknown/unset | +| source | [string](#string) | | Usually based on thread name - if known | +| level | [LogRecord.Level](#LogRecord.Level) | | Not yet set | + + + + + + ### MeshPacket @@ -508,6 +517,23 @@ How our location is shared with other nodes (or the local phone) + + +### LogRecord.Level +Log levels, chosen to match python logging conventions. + +| Name | Number | Description | +| ---- | ------ | ----------- | +| UNSET | 0 | | +| CRITICAL | 50 | | +| ERROR | 40 | | +| WARNING | 30 | | +| INFO | 20 | | +| DEBUG | 10 | | +| TRACE | 5 | | + + + ### RegionCode diff --git a/mesh.options b/mesh.options index 3c09977..2492e18 100644 --- a/mesh.options +++ b/mesh.options @@ -45,6 +45,9 @@ # Max of three ignored nodes for our testing *UserPreferences.ignore_incoming max_count:3 +*LogRecord.message max_size:64 +*LogRecord.source max_size:8 + # MyMessage.name max_size:40 # or fixed_length or fixed_count, or max_count diff --git a/mesh.proto b/mesh.proto index f1fef18..64832dc 100644 --- a/mesh.proto +++ b/mesh.proto @@ -816,11 +816,36 @@ message DeviceState { repeated ChannelSettings secondary_channels = 12; } -/// Debug output from the device -message DebugString { +/** 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 contuinuation of the previously sent message. This allows + the device code to use fixed maxlen 64 byte strings for messages, and then extend as needed by + emitting multiple records. +*/ +message LogRecord { + + /** Log levels, chosen to match python logging conventions. */ + enum Level { + UNSET = 0; + CRITICAL = 50; + ERROR = 40; + WARNING = 30; + INFO = 20; + DEBUG = 10; + TRACE = 5; + } + string message = 1; - // eventually we might add source and level + /** Seconds since 1970 - or 0 for unknown/unset */ + fixed32 time = 2; + + /** Usually based on thread name - if known */ + string source = 3; + + /** Not yet set */ + Level level = 4; } // packets from the radio to the phone will appear on the fromRadio @@ -848,7 +873,7 @@ message FromRadio { RadioConfig radio = 6; // set to send debug console output over our protobuf stream - DebugString debug_string = 7; + LogRecord log_record = 7; // sent as true once the device has finished sending all of the // responses to want_config From 72f29307090c0283ec197e322a0cc784ae8337e9 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Sun, 27 Dec 2020 10:55:59 +0800 Subject: [PATCH 12/25] update docs --- docs/docs.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/docs.md b/docs/docs.md index 51571fd..1c629f6 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -339,7 +339,7 @@ see sw-design.md for more information on these preferences | wifi_ap_mode | [bool](#bool) | | If set, the node will operate as an AP (and DHCP server), otherwise it will be a station | | region | [RegionCode](#RegionCode) | | The region code for my radio (US, CN, EU433, etc...) | | is_router | [bool](#bool) | | Are we operating as a router. Changes behavior in the following ways: The device will only sleep for critically low battery level (i.e. always tries to stay alive for the mesh) In the future routing decisions will preferentially route packets through nodes with this attribute (because assumed good line of sight) | -| is_low_power | [bool](#bool) | | If set, we are powered from a low-current source (i.e. solar), so even if it looks like we have power flowing in we should try to minimize power consumption as much as possible. Often combined with is_router. | +| is_low_power | [bool](#bool) | | If set, we are powered from a low-current source (i.e. solar), so even if it looks like we have power flowing in we should try to minimize power consumption as much as possible. YOU DO NOT NEED TO SET THIS IF YOU'VE set is_router (it is implied in that case). | | fixed_position | [bool](#bool) | | If set, this node is at a fixed position. We will generate GPS position updates at the regular interval, but use whatever the last lat/lon/alt we have for the node. The lat/lon/alt can be set by an internal GPS or with the help of the app. | | factory_reset | [bool](#bool) | | This setting is never saved to disk, but if set, all device settings will be returned to factory defaults. (Region, serial number etc... will be preserved) | | debug_log_enabled | [bool](#bool) | | 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. | @@ -603,7 +603,6 @@ master table. PortNums should be assigned in the following range: 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 -1024-66559 Are reserved for use by IP tunneling (see FIXME for more information) All other values are reserved. @@ -620,8 +619,8 @@ This change is backwards compatible by treating the legacy OPAQUE/CLEAR_TEXT val | POSITION_APP | 3 | The built-in position messaging app. See Position for details on the message sent to this port number. | | NODEINFO_APP | 4 | The built-in user info app. See User for details on the message sent to this port number. | | REPLY_APP | 32 | Provides a 'ping' service that replies to any packet it receives. Also this serves as a small example plugin. | +| IP_TUNNEL_APP | 33 | Used for the python IP tunnel feature | | PRIVATE_APP | 256 | Private applications should use portnums >= 256. To simplify initial development and testing you can use "PRIVATE_APP" in your code without needing to rebuild protobuf files (via bin/regin_protos.sh) | -| IP_TUNNEL_APP | 1024 | 1024-66559 Are reserved for use by IP tunneling (see FIXME for more information) | From 9a7d8a03cb051eb42787d4a06836b109677d8ef1 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Sun, 27 Dec 2020 11:07:58 +0800 Subject: [PATCH 13/25] move error code defs to .proto so that other platforms can easily parse --- docs/docs.md | 23 ++++++++++++++++++++++- mesh.proto | 29 ++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/docs/docs.md b/docs/docs.md index 1c629f6..ff2a1a5 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -22,6 +22,7 @@ - [ChannelSettings.ModemConfig](#.ChannelSettings.ModemConfig) - [Constants](#.Constants) + - [CriticalErrorCode](#.CriticalErrorCode) - [GpsOperation](#.GpsOperation) - [LocationSharing](#.LocationSharing) - [LogRecord.Level](#.LogRecord.Level) @@ -246,7 +247,7 @@ Sent to the phone in response to WantNodes. | region | [string](#string) | | The region code for my radio (US, CN, etc...) Note: This string is deprecated. The 1.0 builds populate it based on the flashed firmware name. But for newer builds this string will be unpopulated (missing/null). For those builds you should instead look at the new read/write region enum in UserSettings The format of this string was 1.0-US or 1.0-CN etc.. Or empty string if unset. | | hw_model | [string](#string) | | TBEAM, HELTEC, etc... | | firmware_version | [string](#string) | | 0.0.5 etc... | -| error_code | [uint32](#uint32) | | An error message we'd like to report back to the mothership through / analytics. It indicates a serious bug occurred on the device, the device / coped with it, but we still want to tell the devs about the bug. This / field will be cleared after the phone reads MyNodeInfo (i.e. it will only / be reported once) a numeric error code to go with error message, zero / means no error | +| error_code | [CriticalErrorCode](#CriticalErrorCode) | | An error message we'd like to report back to the mothership through / analytics. It indicates a serious bug occurred on the device, the device / coped with it, but we still want to tell the devs about the bug. This / field will be cleared after the phone reads MyNodeInfo (i.e. it will only / be reported once) a numeric error code to go with error message, zero / means no error | | error_address | [uint32](#uint32) | | A numeric error address (nonzero if available) | | error_count | [uint32](#uint32) | | The total number of errors this node has ever encountered (well - since / the last time we discarded preferences) | | packet_id_bits | [uint32](#uint32) | | How many bits are used for the packetid. If zero it is assumed we use eight bit packetids Old device loads (older that 0.6.5 do not populate this field, but all newer loads do). | @@ -488,6 +489,26 @@ Shared constants between device and phone + + +### CriticalErrorCode +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. + +| Name | Number | Description | +| ---- | ------ | ----------- | +| None | 0 | | +| TxWatchdog | 1 | A software bug was detected while trying to send lora | +| SleepEnterWait | 2 | A software bug was detected on entry to sleep | +| NoRadio | 3 | No Lora radio hardware could be found | +| Unspecified | 4 | Not normally used | +| UBloxInitFailed | 5 | We failed while configuring a UBlox GPS | +| NoAXP192 | 6 | This board was expected to have a power management chip and it is missing or broken | + + + ### GpsOperation diff --git a/mesh.proto b/mesh.proto index 2ba394a..f07da44 100644 --- a/mesh.proto +++ b/mesh.proto @@ -681,6 +681,33 @@ message NodeInfo { uint32 next_hop = 5; } +/** 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. + */ +enum CriticalErrorCode { + None = 0; + + /// A software bug was detected while trying to send lora + TxWatchdog = 1; + + /// A software bug was detected on entry to sleep + SleepEnterWait = 2; + + /// No Lora radio hardware could be found + NoRadio = 3; + + /// Not normally used + Unspecified = 4; + + /// We failed while configuring a UBlox GPS + UBloxInitFailed = 5; + + /// This board was expected to have a power management chip and it is missing or broken + NoAXP192 = 6; +} + /** Unique local debugging info for this node @@ -725,7 +752,7 @@ message MyNodeInfo { /// field will be cleared after the phone reads MyNodeInfo (i.e. it will only /// be reported once) a numeric error code to go with error message, zero /// means no error - uint32 error_code = 7; + CriticalErrorCode error_code = 7; /// A numeric error address (nonzero if available) uint32 error_address = 8; From 323b814f4392ae0f9c42a0f14557c6b9333efce3 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Sun, 27 Dec 2020 13:07:46 +0800 Subject: [PATCH 14/25] add InvalidRadioSetting critical fault in support of https://github.com/meshtastic/Meshtastic-device/issues/577 --- docs/docs.md | 1 + mesh.proto | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/docs.md b/docs/docs.md index ff2a1a5..5400f54 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -506,6 +506,7 @@ post on the meshtastic.discourse.group and we'll try to help. | Unspecified | 4 | Not normally used | | UBloxInitFailed | 5 | We failed while configuring a UBlox GPS | | NoAXP192 | 6 | This board was expected to have a power management chip and it is missing or broken | +| InvalidRadioSetting | 7 | The channel tried to set a radio setting which is not supported by this chipset, radio comms settings are now undefined. | diff --git a/mesh.proto b/mesh.proto index f07da44..c53d2e5 100644 --- a/mesh.proto +++ b/mesh.proto @@ -689,23 +689,27 @@ message NodeInfo { enum CriticalErrorCode { None = 0; - /// A software bug was detected while trying to send lora + // A software bug was detected while trying to send lora TxWatchdog = 1; - /// A software bug was detected on entry to sleep + // A software bug was detected on entry to sleep SleepEnterWait = 2; - /// No Lora radio hardware could be found + // No Lora radio hardware could be found NoRadio = 3; - /// Not normally used + // Not normally used Unspecified = 4; - /// We failed while configuring a UBlox GPS + // We failed while configuring a UBlox GPS UBloxInitFailed = 5; - /// This board was expected to have a power management chip and it is missing or broken + // This board was expected to have a power management chip and it is missing or broken NoAXP192 = 6; + + // The channel tried to set a radio setting which is not supported by this chipset, + // radio comms settings are now undefined. + InvalidRadioSetting = 7; } /** From 5a23071d2363725ca954562f00bfca0d5717ca79 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Mon, 28 Dec 2020 13:12:14 +0800 Subject: [PATCH 15/25] move device only code into a separate file --- deviceonly.options | 11 +++++ deviceonly.proto | 50 +++++++++++++++++++++++ docs/docs.md | 100 ++++++++++++++++++++++++++++----------------- mesh.options | 8 ---- mesh.proto | 99 ++++++++++++++++++++------------------------ 5 files changed, 169 insertions(+), 99 deletions(-) create mode 100644 deviceonly.options create mode 100644 deviceonly.proto diff --git a/deviceonly.options b/deviceonly.options new file mode 100644 index 0000000..e8fb491 --- /dev/null +++ b/deviceonly.options @@ -0,0 +1,11 @@ +# options for nanopb +# https://jpa.kapsi.fi/nanopb/docs/reference.html#proto-file-options + +# FIXME pick a higher number someday? or do dynamic alloc in nanopb? +*DeviceState.node_db max_count:32 + +# FIXME - max_count is actually 32 but we save/load this as one long string of preencoded MeshPacket bytes - not a big array in RAM +*DeviceState.receive_queue max_count:1 + +*DeviceState.secondary_channels max_count:4 + diff --git a/deviceonly.proto b/deviceonly.proto new file mode 100644 index 0000000..c08982c --- /dev/null +++ b/deviceonly.proto @@ -0,0 +1,50 @@ +syntax = "proto3"; + +option java_package = "com.geeksville.mesh"; +option java_outer_classname = "MeshProtos"; +option optimize_for = LITE_RUNTIME; + +import "mesh.proto"; + +// This message is never sent over the wire, but it is used for serializing DB +// state to flash in the device code +// FIXME, since we write this each time we enter deep sleep (and have infinite +// flash) it would be better to use some sort of append only data structure for +// the receive queue and use the preferences store for the other stuff +message DeviceState { + RadioConfig radio = 1; + + /// Read only settings/info about this node + MyNodeInfo my_node = 2; + + /// My owner info + User owner = 3; + + repeated NodeInfo node_db = 4; + + /// Received packets saved for delivery to the phone + repeated MeshPacket receive_queue = 5; + + /** A version integer used to invalidate old save files when we make + incompatible changes This integer is set at build time and is private to + NodeDB.cpp in the device code. */ + uint32 version = 8; + + // We keep the last received text message (only) stored in the device flash, + // so we can show it on the screen. Might be null + MeshPacket rx_text_message = 7; + + // Used only during development. Indicates developer is testing and changes + // should never be saved to flash. + bool no_save = 9; + + // Some GPSes seem to have bogus settings from the factory, so we always do + // one factory reset + bool did_gps_reset = 11; + + /** Secondary channels are only used for encryption/decryption/authentication purposes. Their radio settings (freq etc) + are ignored, only psk is used. + Note: this is not kept inside of RadioConfig because that would make ToRadio/FromRadio worse case > 512 bytes (to big for BLE) + */ + repeated ChannelSettings secondary_channels = 12; + } \ No newline at end of file diff --git a/docs/docs.md b/docs/docs.md index 5400f54..0195f4a 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -3,10 +3,12 @@ ## Table of Contents +- [deviceonly.proto](#deviceonly.proto) + - [DeviceState](#.DeviceState) + - [mesh.proto](#mesh.proto) - [ChannelSettings](#.ChannelSettings) - [Data](#.Data) - - [DeviceState](#.DeviceState) - [FromRadio](#.FromRadio) - [LogRecord](#.LogRecord) - [MeshPacket](#.MeshPacket) @@ -41,6 +43,50 @@ + +

Top

+ +## deviceonly.proto + + + + + +### DeviceState +This message is never sent over the wire, but it is used for serializing DB +state to flash in the device code +FIXME, since we write this each time we enter deep sleep (and have infinite +flash) it would be better to use some sort of append only data structure for +the receive queue and use the preferences store for the other stuff + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| radio | [RadioConfig](#RadioConfig) | | | +| my_node | [MyNodeInfo](#MyNodeInfo) | | Read only settings/info about this node | +| owner | [User](#User) | | My owner info | +| node_db | [NodeInfo](#NodeInfo) | repeated | | +| receive_queue | [MeshPacket](#MeshPacket) | repeated | Received packets saved for delivery to the phone | +| version | [uint32](#uint32) | | A version integer used to invalidate old save files when we make incompatible changes This integer is set at build time and is private to NodeDB.cpp in the device code. | +| rx_text_message | [MeshPacket](#MeshPacket) | | We keep the last received text message (only) stored in the device flash, so we can show it on the screen. Might be null | +| no_save | [bool](#bool) | | Used only during development. Indicates developer is testing and changes should never be saved to flash. | +| did_gps_reset | [bool](#bool) | | Some GPSes seem to have bogus settings from the factory, so we always do one factory reset | +| secondary_channels | [ChannelSettings](#ChannelSettings) | repeated | Secondary channels are only used for encryption/decryption/authentication purposes. Their radio settings (freq etc) are ignored, only psk is used. Note: this is not kept inside of RadioConfig because that would make ToRadio/FromRadio worse case > 512 bytes (to big for BLE) | + + + + + + + + + + + + + + +

Top

@@ -74,6 +120,7 @@ Full settings (center freq, spread factor, pre-shared secret key etc...) needed to configure a radio for speaking on a particlar channel This information can be encoded as a QRcode/url so that other users can configure their radio to join the same channel. + A note aboute how channel names are shown to users: channelname-Xy poundsymbol is a prefix used to indicate this is a channel name (idea from @professr). @@ -88,6 +135,11 @@ 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 + | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | @@ -99,6 +151,9 @@ Y is a lower case letter from a-z that represents the channel 'speed' se | channel_num | [uint32](#uint32) | | A channel number between 1 and 13 (or whatever the max is in the current region). If ZERO then the rule is "use the old channel name hash based algoritm to derive the channel number") If using the hash algorithm the channel number will be: hash(channel_name) % NUM_CHANNELS (Where num channels depends on the regulatory region). NUM_CHANNELS_US is 13, for other values see MeshRadio.h in the device code. hash a string into an integer - djb2 by Dan Bernstein. - http://www.cse.yorku.ca/~oz/hash.html unsigned long hash(char *str) { unsigned long hash = 5381; int c; while ((c = *str++) != 0) hash = ((hash << 5) + hash) + (unsigned char) c; return hash; } | | psk | [bytes](#bytes) | | A simple preshared key for now for crypto. Must be either 0 bytes (no crypto), 16 bytes (AES128), or 32 bytes (AES256) A special shorthand is used for 1 byte long psks. These psks should be treated as only minimally secure, because they are listed in this source code. Those bytes are mapped using the following scheme: 0 = No crypto 1 = The special default channel key: {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59, 0xf0, 0xbc, 0xff, 0xab, 0xcf, 0x4e, 0x69, 0xbf} 2 through 10 = The default channel key, except with 1 through 9 added to the last byte | | name | [string](#string) | | A SHORT name that will be packed into the URL. Less than 12 bytes. Something for end users to call the channel If this is the empty string it is assumed that this channel is the special (minimially secure) "Default" channel. In user interfaces it should be rendered as a local language translation of "X". For channel_num hashing empty string will be treated as "X". Where "X" is selected based on the english words listed above for ModemConfig | +| id | [fixed32](#fixed32) | | Used to construct a globally unique channel ID. The full globally unique ID will be: "name.id" where ID is shown as base36. Assuming that the number of meshtastic users is below 20K (true for a long time) the chance of this 64 bit random number colliding with anyone else is super low. And the penalty for collision is low as well, it just means that anyone trying to decrypt channel messages might need to try multiple candidate channels. Any time a non wire compatible change is made to a channel, this field should be regenerated. There are a small number of 'special' globally known (and fairly) insecure standard channels. Those channels do not have a numeric id included in the settings, but instead it is pulled from a table of well known IDs. (see Well Known Channels FIXME) | +| uplink_enabled | [bool](#bool) | | If true, messages on the mesh will be sent to the *public* internet by any gateway ndoe | +| downlink_enabled | [bool](#bool) | | If true, messages seen on the internet will be forwarded to the local mesh. | @@ -122,36 +177,6 @@ internally in the case of CLEAR_TEXT and CLEAR_READACK) - - -### DeviceState -This message is never sent over the wire, but it is used for serializing DB -state to flash in the device code -FIXME, since we write this each time we enter deep sleep (and have infinite -flash) it would be better to use some sort of append only data structure for -the receive queue and use the preferences store for the other stuff - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| radio | [RadioConfig](#RadioConfig) | | | -| my_node | [MyNodeInfo](#MyNodeInfo) | | Read only settings/info about this node | -| owner | [User](#User) | | My owner info | -| node_db | [NodeInfo](#NodeInfo) | repeated | | -| receive_queue | [MeshPacket](#MeshPacket) | repeated | Received packets saved for delivery to the phone | -| version | [uint32](#uint32) | | A version integer used to invalidate old save files when we make incompatible changes This integer is set at build time and is private to NodeDB.cpp in the device code. | -| rx_text_message | [MeshPacket](#MeshPacket) | | We keep the last received text message (only) stored in the device flash, so we can show it on the screen. Might be null | -| no_save | [bool](#bool) | | Used only during development. Indicates developer is testing and changes should never be saved to flash. | -| did_gps_reset | [bool](#bool) | | Some GPSes seem to have bogus settings from the factory, so we always do one factory reset | -| secondary_channels | [ChannelSettings](#ChannelSettings) | repeated | Secondary channels are only used for encryption/decryption/authentication purposes. Their radio settings (freq etc) are ignored, only psk is used. - -Note: this is not kept inside of RadioConfig because that would make ToRadio/FromRadio worse case > 512 bytes (to big for BLE) | - - - - - - ### FromRadio @@ -172,7 +197,7 @@ FIFO will be populated. | log_record | [LogRecord](#LogRecord) | | set to send debug console output over our protobuf stream | | config_complete_id | [uint32](#uint32) | | sent as true once the device has finished sending all of the responses to want_config recipient should check if this ID matches our original request nonce, if not, it means your config responses haven't started yet | | rebooted | [bool](#bool) | | Sent to tell clients the radio has just rebooted. Set to true if present. Not used on all transports, currently just used for the serial console. | -| secondary_channel | [ChannelSettings](#ChannelSettings) | | One of the secondary channels, they are all sent during config download | +| channel | [ChannelSettings](#ChannelSettings) | | One of the channels, they are all sent during config download The first channel is the "primary" channel all other channels are secondary channels The primary channel is also sent as part of RadioConfig (which is deprecated, but to support older clients) | @@ -215,7 +240,7 @@ MeshPacket). | ----- | ---- | ----- | ----------- | | from | [uint32](#uint32) | | The sending node number. Note: Our crypto implementation uses this field as well. See docs/software/crypto.md for details. FIXME - really should be fixed32 instead, this encoding only hurts the ble link though. | | to | [uint32](#uint32) | | The (immediate) destination for this packet. If we are using routing, the final destination will be in payload.dest FIXME - really should be fixed32 instead, this encoding only hurts the ble link though. | -| channel_index | [uint32](#uint32) | | If set, this indicates the index in the secondary_channels table that this packet was sent/received on. If unset, packet was on the primary channel. | +| channel_index | [uint32](#uint32) | | If set, this indicates the index in the secondary_channels table that this packet was sent/received on. If unset, packet was on the primary channel. A particular node might know only a subset of channels in use on the mesh. Therefore channel_index is inherently a local concept and meaningless to send between nodes. | | decoded | [SubPacket](#SubPacket) | | | | encrypted | [bytes](#bytes) | | | | id | [uint32](#uint32) | | A unique ID for this packet. Always 0 for no-ack packets or non broadcast packets (and therefore take zero bytes of space). Otherwise a unique ID for this packet. Useful for flooding algorithms. ID only needs to be unique on a _per sender_ basis. And it only needs to be unique for a few minutes (long enough to last for the length of any ACK or the completion of a mesh broadcast flood). Note: Our crypto implementation uses this id as well. See docs/software/crypto.md for details. FIXME - really should be fixed32 instead, this encoding only hurts the ble link though. | @@ -310,7 +335,7 @@ set for behavior of their node | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | preferences | [RadioConfig.UserPreferences](#RadioConfig.UserPreferences) | | | -| channel_settings | [ChannelSettings](#ChannelSettings) | | | +| channel_settings | [ChannelSettings](#ChannelSettings) | | The preferred way to find channel settings is now in FromRadio. | @@ -379,12 +404,12 @@ inside a radio packet (because from/to are broken out by the comms library) | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| position | [Position](#Position) | | Prior to 1.20 positions were communicated as a special payload type, now they are GPS_POSITION_APP Data | | data | [Data](#Data) | | | -| user | [User](#User) | | Prior to 1.20 positions were communicated as a special payload type, now they are MESH_USERINFO_APP | -| route_request | [RouteDiscovery](#RouteDiscovery) | | A route request going from the requester | +| route_request | [RouteDiscovery](#RouteDiscovery) | | A route request going from the requester FIXME - these route messages should be moved into regular data packets and use the regular on device plugin mechanism. | | route_reply | [RouteDiscovery](#RouteDiscovery) | | A route reply | | route_error | [RouteError](#RouteError) | | A failure in a routed message | +| position | [Position](#Position) | | Prior to 1.20 positions were communicated as a special payload type, now they are GPS_POSITION_APP Data | +| user | [User](#User) | | Prior to 1.20 positions were communicated as a special payload type, now they are MESH_USERINFO_APP | | want_response | [bool](#bool) | | Not normally used, but for testing a sender can request that recipient responds in kind (i.e. if it received a position, it should unicast back its position). Note: that if you set this on a broadcast you will receive many replies. | | success_id | [uint32](#uint32) | | This packet is a requested acknoledgement indicating that we have received the specified message ID. This packet type can be used both for immediate (0 hops) messages or can be routed through multiple hops if dest is set. Note: As an optimization, recipients can _also_ populate a field in payload if they think the recipient would appreciate that extra state. | | fail_id | [uint32](#uint32) | | This is a nak, we failed to deliver this message. | @@ -410,6 +435,7 @@ characteristic. Once the write completes the phone can assume it is handled. | want_config_id | [uint32](#uint32) | | phone wants radio to send full node db to the phone, This is typically the first packet sent to the radio when the phone gets a bluetooth connection. The radio will respond by sending back a MyNodeInfo, a owner, a radio config and a series of FromRadio.node_infos, and config_complete the integer you write into this field will be reported back in the config_complete_id response this allows clients to never be confused by a stale old partially sent config. | | set_radio | [RadioConfig](#RadioConfig) | | set the radio provisioning for this node | | set_owner | [User](#User) | | Set the owner for this node | +| set_channel | [ChannelSettings](#ChannelSettings) | | Set channels (using the new API). The first sent channel is assumed to be channel index 0 the "primary channel". Following records are secondary channels. | diff --git a/mesh.options b/mesh.options index 2492e18..9f0ec88 100644 --- a/mesh.options +++ b/mesh.options @@ -7,14 +7,6 @@ *User.long_name max_size:40 *User.short_name max_size:5 -# FIXME pick a higher number someday? or do dynamic alloc in nanopb? -*DeviceState.node_db max_count:32 - -# FIXME - max_count is actually 32 but we save/load this as one long string of preencoded MeshPacket bytes - not a big array in RAM -*DeviceState.receive_queue max_count:1 - -*DeviceState.secondary_channels max_count:4 - *RouteDiscovery.route max_count:8 # FIXME, max out based on total SubPacket size And do fragmentation and reassembly (for larger payloads) at the Android layer, not the esp32 layer. diff --git a/mesh.proto b/mesh.proto index c53d2e5..5bb080a 100644 --- a/mesh.proto +++ b/mesh.proto @@ -138,16 +138,12 @@ message SubPacket { // Only one of the following fields can be populated at a time oneof payload { - /// Prior to 1.20 positions were communicated as a special payload type, now they are GPS_POSITION_APP Data - Position position = 1 [deprecated = true]; - Data data = 3; - /// Prior to 1.20 positions were communicated as a special payload type, now they are MESH_USERINFO_APP - User user = 4 [deprecated = true]; - /** A route request going from the requester + FIXME - these route messages should be moved into regular data packets and use the regular on + device plugin mechanism. */ RouteDiscovery route_request = 6; @@ -160,6 +156,12 @@ message SubPacket { A failure in a routed message */ RouteError route_error = 13; + + // Prior to 1.20 positions were communicated as a special payload type, now they are GPS_POSITION_APP Data + Position position = 1 [deprecated = true]; + + // Prior to 1.20 positions were communicated as a special payload type, now they are MESH_USERINFO_APP + User user = 4 [deprecated = true]; } // Not normally used, but for testing a sender can request that recipient @@ -232,6 +234,8 @@ message MeshPacket { /** If set, this indicates the index in the secondary_channels table that this packet was sent/received on. If unset, packet was on the primary channel. + A particular node might know only a subset of channels in use on the mesh. Therefore channel_index + is inherently a local concept and meaningless to send between nodes. */ uint32 channel_index = 4; @@ -321,6 +325,7 @@ enum Constants { needed to configure a radio for speaking on a particlar channel This information can be encoded as a QRcode/url so that other users can configure their radio to join the same channel. + A note aboute how channel names are shown to users: channelname-Xy poundsymbol is a prefix used to indicate this is a channel name (idea from @professr). @@ -334,6 +339,11 @@ This also allows the option of someday if people have the PSK off (zero), the 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 */ message ChannelSettings { @@ -428,8 +438,24 @@ message ChannelSettings { // channel. In user interfaces it should be rendered as a local language translation of "X". For channel_num // hashing empty string will be treated as "X". // Where "X" is selected based on the english words listed above for ModemConfig - // string name = 5; + + // Used to construct a globally unique channel ID. The full globally unique ID will be: "name.id" + // where ID is shown as base36. Assuming that the number of meshtastic users is below 20K (true for a long time) + // the chance of this 64 bit random number colliding with anyone else is super low. And the penalty for + // collision is low as well, it just means that anyone trying to decrypt channel messages might need to + // try multiple candidate channels. + // Any time a non wire compatible change is made to a channel, this field should be regenerated. + // There are a small number of 'special' globally known (and fairly) insecure standard channels. + // Those channels do not have a numeric id included in the settings, but instead it is pulled from + // a table of well known IDs. (see Well Known Channels FIXME) + fixed32 id = 10; + + // If true, messages on the mesh will be sent to the *public* internet by any gateway ndoe + bool uplink_enabled = 16; + + // If true, messages seen on the internet will be forwarded to the local mesh. + bool downlink_enabled = 17; } /** @@ -617,7 +643,9 @@ message RadioConfig { } UserPreferences preferences = 1; - ChannelSettings channel_settings = 2; + + // The preferred way to find channel settings is now in FromRadio. + ChannelSettings channel_settings = 2 [ deprecated = true ]; } /** @@ -804,50 +832,6 @@ message MyNodeInfo { /// FIXME - add more useful debugging state (queue depths etc) } -// This message is never sent over the wire, but it is used for serializing DB -// state to flash in the device code -// FIXME, since we write this each time we enter deep sleep (and have infinite -// flash) it would be better to use some sort of append only data structure for -// the receive queue and use the preferences store for the other stuff -message DeviceState { - RadioConfig radio = 1; - - /// Read only settings/info about this node - MyNodeInfo my_node = 2; - - /// My owner info - User owner = 3; - - repeated NodeInfo node_db = 4; - - /// Received packets saved for delivery to the phone - repeated MeshPacket receive_queue = 5; - - /** A version integer used to invalidate old save files when we make - incompatible changes This integer is set at build time and is private to - NodeDB.cpp in the device code. */ - uint32 version = 8; - - // We keep the last received text message (only) stored in the device flash, - // so we can show it on the screen. Might be null - MeshPacket rx_text_message = 7; - - // Used only during development. Indicates developer is testing and changes - // should never be saved to flash. - bool no_save = 9; - - // Some GPSes seem to have bogus settings from the factory, so we always do - // one factory reset - bool did_gps_reset = 11; - - /** Secondary channels are only used for encryption/decryption/authentication purposes. Their radio settings (freq etc) - are ignored, only psk is used. - - Note: this is not kept inside of RadioConfig because that would make ToRadio/FromRadio worse case > 512 bytes (to big for BLE) - */ - repeated ChannelSettings secondary_channels = 12; -} - /** Debug output from the device. To minimize the size of records inside the device code, if a time/source/level is not set @@ -918,8 +902,11 @@ message FromRadio { // console. bool rebooted = 9; - // One of the secondary channels, they are all sent during config download - ChannelSettings secondary_channel = 10; + // One of the channels, they are all sent during config download + // The first channel is the "primary" channel all other channels are secondary channels + // The primary channel is also sent as part of RadioConfig (which is deprecated, but to support + // older clients) + ChannelSettings channel = 10; } } @@ -945,6 +932,10 @@ message ToRadio { // Set the owner for this node User set_owner = 102; + + // Set channels (using the new API). The first sent channel is assumed to be channel + // index 0 the "primary channel". Following records are secondary channels. + ChannelSettings set_channel = 103; } } From a66504ed6404ed967799e8b4441e4a2adbe62660 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Mon, 28 Dec 2020 13:34:14 +0800 Subject: [PATCH 16/25] work on mqtt/multichannel --- apponly.proto | 23 +++++++++++++++++++++++ deviceonly.proto | 2 +- docs/docs.md | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 apponly.proto diff --git a/apponly.proto b/apponly.proto new file mode 100644 index 0000000..4f02a22 --- /dev/null +++ b/apponly.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; + +option java_package = "com.geeksville.mesh"; +option java_outer_classname = "AppOnly"; +option optimize_for = LITE_RUNTIME; + +import "mesh.proto"; + +/** +This message wraps a MeshPacket with extra metadata about the sender and how it arrived. +*/ +message ServiceEnvelope { + /** The (probably encrypted) packet */ + MeshPacket packet = 1; + + /** The global channel ID it was sent on */ + string channel_id = 2; + + /** The sending mesh. FIXME, is this necessary? can we use this to authenticate/prevent fake + nodeid impersonation for senders - i.e. use mesh id (which is authenticated) + local node id as + the globally trusted nodenum */ + string mesh_id = 3; +} \ No newline at end of file diff --git a/deviceonly.proto b/deviceonly.proto index c08982c..a8f615c 100644 --- a/deviceonly.proto +++ b/deviceonly.proto @@ -1,7 +1,7 @@ syntax = "proto3"; option java_package = "com.geeksville.mesh"; -option java_outer_classname = "MeshProtos"; +option java_outer_classname = "DeviceOnly"; option optimize_for = LITE_RUNTIME; import "mesh.proto"; diff --git a/docs/docs.md b/docs/docs.md index 0195f4a..afd80f7 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -3,6 +3,9 @@ ## Table of Contents +- [apponly.proto](#apponly.proto) + - [ServiceEnvelope](#.ServiceEnvelope) + - [deviceonly.proto](#deviceonly.proto) - [DeviceState](#.DeviceState) @@ -43,6 +46,39 @@ + +

Top

+ +## apponly.proto + + + + + +### ServiceEnvelope +This message wraps a MeshPacket with extra metadata about the sender and how it arrived. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| packet | [MeshPacket](#MeshPacket) | | The (probably encrypted) packet | +| channel_id | [string](#string) | | The global channel ID it was sent on | +| mesh_id | [string](#string) | | The sending mesh. FIXME, is this necessary? can we use this to authenticate/prevent fake nodeid impersonation for senders - i.e. use mesh id (which is authenticated) + local node id as the globally trusted nodenum | + + + + + + + + + + + + + + +

Top

From 3e492ad2d5319a9d5aa464cf180f9fe2ab107cfb Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Mon, 28 Dec 2020 14:38:51 +0800 Subject: [PATCH 17/25] doc updates --- apponly.proto | 6 +++--- deviceonly.options | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apponly.proto b/apponly.proto index 4f02a22..533f9ca 100644 --- a/apponly.proto +++ b/apponly.proto @@ -16,8 +16,8 @@ message ServiceEnvelope { /** The global channel ID it was sent on */ string channel_id = 2; - /** The sending mesh. FIXME, is this necessary? can we use this to authenticate/prevent fake - nodeid impersonation for senders - i.e. use mesh id (which is authenticated) + local node id as + /** The sending gateway. Can we use this to authenticate/prevent fake + nodeid impersonation for senders? - i.e. use gateway/mesh id (which is authenticated) + local node id as the globally trusted nodenum */ - string mesh_id = 3; + string gateway_id = 3; } \ No newline at end of file diff --git a/deviceonly.options b/deviceonly.options index e8fb491..10f8818 100644 --- a/deviceonly.options +++ b/deviceonly.options @@ -7,5 +7,5 @@ # FIXME - max_count is actually 32 but we save/load this as one long string of preencoded MeshPacket bytes - not a big array in RAM *DeviceState.receive_queue max_count:1 -*DeviceState.secondary_channels max_count:4 +*DeviceState.secondary_channels max_count:7 From dfe7bc1217a00c23eecb9dfcf1d56fe95ebddc3b Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Wed, 30 Dec 2020 12:24:39 +0800 Subject: [PATCH 18/25] doc updates --- docs/docs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs.md b/docs/docs.md index afd80f7..6df00a3 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -63,7 +63,7 @@ This message wraps a MeshPacket with extra metadata about the sender and how it | ----- | ---- | ----- | ----------- | | packet | [MeshPacket](#MeshPacket) | | The (probably encrypted) packet | | channel_id | [string](#string) | | The global channel ID it was sent on | -| mesh_id | [string](#string) | | The sending mesh. FIXME, is this necessary? can we use this to authenticate/prevent fake nodeid impersonation for senders - i.e. use mesh id (which is authenticated) + local node id as the globally trusted nodenum | +| gateway_id | [string](#string) | | The sending gateway. Can we use this to authenticate/prevent fake nodeid impersonation for senders? - i.e. use gateway/mesh id (which is authenticated) + local node id as the globally trusted nodenum | From 04bc6b41a44a40f09193e0e27b8976d91f09d360 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Tue, 12 Jan 2021 21:53:16 -0800 Subject: [PATCH 19/25] SerialPlugin using port 64 --- portnums.proto | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/portnums.proto b/portnums.proto index 422b6ca..a81fa84 100644 --- a/portnums.proto +++ b/portnums.proto @@ -72,7 +72,17 @@ enum PortNum { /** Used for the python IP tunnel feature */ IP_TUNNEL_APP = 33; + /** Provides a hardware serial interface to send and receive from the Meshtastic network. + Connect to the RX/TX pins of a device with 38400 8N1. Packets received from the Meshtastic + network is forwarded to the RX pin while sending a packet to TX will go out to the Mesh + network. Maximum packet size of 240 bytes. + + Plugin is disabled by default can be turned on by setting SERIALPLUGIN_ENABLED = 1 in + SerialPlugh.cpp. + */ + SERIAL_APP = 64; + /** Private applications should use portnums >= 256. To simplify initial development and testing you can use "PRIVATE_APP" in your code without needing to rebuild protobuf files (via bin/regin_protos.sh) */ PRIVATE_APP = 256; - } \ No newline at end of file + } From 4c62d8e53696074d7c368518afd9d564df374fcf Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Tue, 12 Jan 2021 21:54:16 -0800 Subject: [PATCH 20/25] Update portnums.proto --- portnums.proto | 3 +++ 1 file changed, 3 insertions(+) diff --git a/portnums.proto b/portnums.proto index a81fa84..f02a253 100644 --- a/portnums.proto +++ b/portnums.proto @@ -79,6 +79,9 @@ enum PortNum { Plugin is disabled by default can be turned on by setting SERIALPLUGIN_ENABLED = 1 in SerialPlugh.cpp. + + Maintained by Jm Casler (MC Hamster) : jm@casler.org + */ SERIAL_APP = 64; From 4f9da902e224b7fdc608b2b19b41818738e4f3e4 Mon Sep 17 00:00:00 2001 From: Paul Mandal Date: Fri, 15 Jan 2021 21:03:21 -0700 Subject: [PATCH 21/25] Add portnum definition for ATAK Forwarder --- portnums.proto | 3 +++ 1 file changed, 3 insertions(+) diff --git a/portnums.proto b/portnums.proto index f02a253..62f03e5 100644 --- a/portnums.proto +++ b/portnums.proto @@ -88,4 +88,7 @@ enum PortNum { /** Private applications should use portnums >= 256. To simplify initial development and testing you can use "PRIVATE_APP" in your code without needing to rebuild protobuf files (via bin/regin_protos.sh) */ PRIVATE_APP = 256; + + /** ATAK Forwarder Plugin https://github.com/paulmandal/atak-forwarder */ + ATAK_FORWARDER = 257; } From 0977dfd8943b7d615f9f9719472c76fff0143016 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 16 Jan 2021 14:49:58 -0800 Subject: [PATCH 22/25] #615 - Allow rate for tbeam battery charger to be configurable --- mesh.proto | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/mesh.proto b/mesh.proto index 5bb080a..21fd8f3 100644 --- a/mesh.proto +++ b/mesh.proto @@ -482,6 +482,30 @@ enum RegionCode { // Add new regions here } +/** + Sets the charge control current of devices with a battery charger that can be + configured. This is passed into the axp power management chip like on the tbeam. +*/ +enum ChargeCurrent { + Unset = 0; + 100MA = 1; + 190MA = 2; + 280MA = 3; + 360MA = 4; + 450MA = 5; + 550MA = 6; + 630MA = 7; + 700MA = 8; + 780MA = 9; + 880MA = 10; + 960MA = 11; + 1000MA = 12; + 1080MA = 13; + 1160MA = 14; + 1240MA = 15; + 1320MA = 16; +} + /** How the GPS hardware in this unit is operated. @@ -565,6 +589,9 @@ message RadioConfig { /// The region code for my radio (US, CN, EU433, etc...) RegionCode region = 15; + /** Sets the current of the battery charger */ + ChargeCurrent charge_current = 16; + /** Are we operating as a router. Changes behavior in the following ways: The device will only sleep for critically low battery level (i.e. always tries to stay alive for the mesh) From ff4ff06d5ee7d5c63d2dd1b7f2c5f8e29a36be11 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 16 Jan 2021 15:02:38 -0800 Subject: [PATCH 23/25] Added preferences for the serialplugin --- mesh.proto | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mesh.proto b/mesh.proto index 21fd8f3..1fdf386 100644 --- a/mesh.proto +++ b/mesh.proto @@ -667,6 +667,18 @@ message RadioConfig { router.cpp) */ repeated uint32 ignore_incoming = 103; + + /** + Preferences for the SerialPlugin + + FIXME - Move this out of UserPreferences and into a section for plugin configuration. + */ + bool serialplugin_enabled = 120; + bool serialplugin_echo = 121; + uint32 serialplugin_rxd = 122; + uint32 serialplugin_txd = 123; + uint32 serialplugin_timeout = 124; + } UserPreferences preferences = 1; From e2c9b17241925fb9e60d9b6c05b89cc5915d5cdd Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 16 Jan 2021 20:42:01 -0800 Subject: [PATCH 24/25] Fix to ChargeCurrent. --- mesh.proto | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/mesh.proto b/mesh.proto index 1fdf386..42eaed3 100644 --- a/mesh.proto +++ b/mesh.proto @@ -488,22 +488,22 @@ enum RegionCode { */ enum ChargeCurrent { Unset = 0; - 100MA = 1; - 190MA = 2; - 280MA = 3; - 360MA = 4; - 450MA = 5; - 550MA = 6; - 630MA = 7; - 700MA = 8; - 780MA = 9; - 880MA = 10; - 960MA = 11; - 1000MA = 12; - 1080MA = 13; - 1160MA = 14; - 1240MA = 15; - 1320MA = 16; + MA100 = 1; + MA190 = 2; + MA280 = 3; + MA360 = 4; + MA450 = 5; + MA550 = 6; + MA630 = 7; + MA700 = 8; + MA780 = 9; + MA880 = 10; + MA960 = 11; + MA1000 = 12; + MA1080 = 13; + MA1160 = 14; + MA1240 = 15; + MA1320 = 16; } /** From 855da8701edbb19818069ad8545d5b9f030bb33f Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Sat, 16 Jan 2021 20:45:10 -0800 Subject: [PATCH 25/25] Fix unset in ChargeCurrent --- mesh.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh.proto b/mesh.proto index 42eaed3..066b547 100644 --- a/mesh.proto +++ b/mesh.proto @@ -487,7 +487,7 @@ enum RegionCode { configured. This is passed into the axp power management chip like on the tbeam. */ enum ChargeCurrent { - Unset = 0; + MAUnset = 0; MA100 = 1; MA190 = 2; MA280 = 3;