From 97138a78dcb82ba16cc93790b590a445f26a7abc Mon Sep 17 00:00:00 2001 From: geeksville Date: Fri, 21 Jun 2024 15:02:05 -0700 Subject: [PATCH 1/2] PowerMon initial protobufs for https://github.com/meshtastic/firmware/issues/4136 --- meshtastic/config.proto | 6 +++++ meshtastic/powermon.proto | 54 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 meshtastic/powermon.proto diff --git a/meshtastic/config.proto b/meshtastic/config.proto index 7805f71..391cb7d 100644 --- a/meshtastic/config.proto +++ b/meshtastic/config.proto @@ -409,6 +409,12 @@ message Config { * I2C address of INA_2XX to use for reading device battery voltage */ uint32 device_battery_ina_address = 9; + + /* + * If non-zero, we want powermon log outputs. With the particular (bitfield) sources enabled. + * Note: we picked an ID of 32 so that lower more efficient IDs can be used for more frequently used options. + */ + uint64 powermon_enables = 32; } /* diff --git a/meshtastic/powermon.proto b/meshtastic/powermon.proto new file mode 100644 index 0000000..8f328b5 --- /dev/null +++ b/meshtastic/powermon.proto @@ -0,0 +1,54 @@ +syntax = "proto3"; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "PowerMonProtos"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; + +package meshtastic.PowerMon; + +/* Any significant power changing event in meshtastic should be tagged with a powermon state transition. + If you are making new meshtastic features feel free to add new entries at the end of this definition. +*/ +enum State { + None = 0; + + CPU_DeepSleep = 0x01; + CPU_LightSleep = 0x02; + + /* + The external Vext1 power is on. Many boards have auxillary power rails that the CPU turns on only + occasionally. In cases where that rail has multiple devices on it we usually want to have logging on + the state of that rail as an independent record. + For instance on the Heltec Tracker 1.1 board, this rail is the power source for the GPS and screen. + */ + Vext1_On = 0x04; + + Lora_RXOn = 0x08; + Lora_TXOn = 0x10; + Lora_RXActive = 0x20; + BT_On = 0x40; + LED_On = 0x80; + + Screen_On = 0x100; + Screen_Drawing = 0x200; + Wifi_On = 0x400; + + /* + GPS is actively trying to find our location + See GPSPowerState for more details + */ + GPS_Active = 0x800; +} + +/* + the log messages will be short and complete (see PowerMon.Event in the protobufs for details). + something like "PwrMon,C,0x00001234,REASON" where the hex number is the bitmask of all current states. + (We use a bitmask for states so that if a log message gets lost it won't be fatal) +*/ +message Event { + + // Bitwise-OR of States + optional uint64 states = 1; +} \ No newline at end of file From a82df2239a9dc4b9d43debeb4e87135b13784ca5 Mon Sep 17 00:00:00 2001 From: geeksville Date: Fri, 21 Jun 2024 16:07:04 -0700 Subject: [PATCH 2/2] Move our namespace into a fake message so the linter doesn't yell. --- meshtastic/powermon.proto | 72 +++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/meshtastic/powermon.proto b/meshtastic/powermon.proto index 8f328b5..7e23bc4 100644 --- a/meshtastic/powermon.proto +++ b/meshtastic/powermon.proto @@ -6,49 +6,47 @@ option java_outer_classname = "PowerMonProtos"; option java_package = "com.geeksville.mesh"; option swift_prefix = ""; -package meshtastic.PowerMon; +package meshtastic; -/* Any significant power changing event in meshtastic should be tagged with a powermon state transition. - If you are making new meshtastic features feel free to add new entries at the end of this definition. +/* Note: There are no 'PowerMon' messages normally in use (PowerMons are sent only as structured logs - slogs). +But we wrap our State enum in this message to effectively nest a namespace (without our linter yelling at us) */ -enum State { - None = 0; - - CPU_DeepSleep = 0x01; - CPU_LightSleep = 0x02; - - /* - The external Vext1 power is on. Many boards have auxillary power rails that the CPU turns on only - occasionally. In cases where that rail has multiple devices on it we usually want to have logging on - the state of that rail as an independent record. - For instance on the Heltec Tracker 1.1 board, this rail is the power source for the GPS and screen. +message PowerMon { + /* Any significant power changing event in meshtastic should be tagged with a powermon state transition. + If you are making new meshtastic features feel free to add new entries at the end of this definition. */ - Vext1_On = 0x04; + enum State { + None = 0; - Lora_RXOn = 0x08; - Lora_TXOn = 0x10; - Lora_RXActive = 0x20; - BT_On = 0x40; - LED_On = 0x80; + CPU_DeepSleep = 0x01; + CPU_LightSleep = 0x02; - Screen_On = 0x100; - Screen_Drawing = 0x200; - Wifi_On = 0x400; + /* + The external Vext1 power is on. Many boards have auxillary power rails that the CPU turns on only + occasionally. In cases where that rail has multiple devices on it we usually want to have logging on + the state of that rail as an independent record. + For instance on the Heltec Tracker 1.1 board, this rail is the power source for the GPS and screen. - /* - GPS is actively trying to find our location - See GPSPowerState for more details - */ - GPS_Active = 0x800; -} + The log messages will be short and complete (see PowerMon.Event in the protobufs for details). + something like "S:PM:C,0x00001234,REASON" where the hex number is the bitmask of all current states. + (We use a bitmask for states so that if a log message gets lost it won't be fatal) + */ + Vext1_On = 0x04; -/* - the log messages will be short and complete (see PowerMon.Event in the protobufs for details). - something like "PwrMon,C,0x00001234,REASON" where the hex number is the bitmask of all current states. - (We use a bitmask for states so that if a log message gets lost it won't be fatal) -*/ -message Event { + Lora_RXOn = 0x08; + Lora_TXOn = 0x10; + Lora_RXActive = 0x20; + BT_On = 0x40; + LED_On = 0x80; - // Bitwise-OR of States - optional uint64 states = 1; + Screen_On = 0x100; + Screen_Drawing = 0x200; + Wifi_On = 0x400; + + /* + GPS is actively trying to find our location + See GPSPowerState for more details + */ + GPS_Active = 0x800; + } } \ No newline at end of file