|
| 1 | +syntax = "proto2"; |
| 2 | + |
| 3 | +package meshtastic; |
| 4 | + |
| 5 | +import "google/protobuf/descriptor.proto"; |
| 6 | + |
| 7 | +option csharp_namespace = "Meshtastic.Protobufs"; |
| 8 | +option go_package = "github.com/meshtastic/go/generated"; |
| 9 | +option java_outer_classname = "FieldMetadataProtos"; |
| 10 | +option java_package = "org.meshtastic.proto"; |
| 11 | +option swift_prefix = ""; |
| 12 | + |
| 13 | +/* |
| 14 | + * Structured, app/UI-relevant metadata describing a protobuf field. |
| 15 | + * |
| 16 | + * Carried in a single FieldOptions extension (`field_metadata` below), so adding |
| 17 | + * an attribute is a SCHEMA-ONLY change: add a new field to this message (use the |
| 18 | + * next field number) and every generated registry — KMP/Wire, C, Python, |
| 19 | + * TypeScript, Rust, Swift — picks it up automatically. No code generator or |
| 20 | + * build change is needed, and no additional FieldOptions extension number is |
| 21 | + * consumed. |
| 22 | + * |
| 23 | + * Constraint: attributes must be SCALAR (bool / int / float / string). A |
| 24 | + * message, enum, bytes, repeated, or map attribute is rejected at generation |
| 25 | + * time (the generators would otherwise emit meaningless, non-deterministic |
| 26 | + * values). See tools/protoc-gen-fieldmeta. |
| 27 | + * |
| 28 | + * To tag a field, set the option on it, e.g. |
| 29 | + * uint32 rx_gpio = 8 [(meshtastic.field_metadata) = { diy_only: true }]; |
| 30 | + * |
| 31 | + * Downstream apps use this to drive UI decisions (e.g. hiding DIY-only settings |
| 32 | + * on pre-assembled boards) directly from the protobuf schema. |
| 33 | + */ |
| 34 | +message FieldMetadata { |
| 35 | + /* |
| 36 | + * Field is only relevant to DIY hardware builds. Apps may hide it when |
| 37 | + * connected to a pre-assembled / commercial board. |
| 38 | + */ |
| 39 | + optional bool diy_only = 1; |
| 40 | + |
| 41 | + /* |
| 42 | + * Field is only relevant in advanced / administrative contexts and may be |
| 43 | + * hidden from the default UI. |
| 44 | + */ |
| 45 | + optional bool admin_only = 2; |
| 46 | + |
| 47 | + /* |
| 48 | + * Inclusive lower bound for the field value, for UI validation/clamping. |
| 49 | + */ |
| 50 | + optional double min_value = 3; |
| 51 | + |
| 52 | + /* |
| 53 | + * Inclusive upper bound for the field value, for UI validation/clamping. |
| 54 | + */ |
| 55 | + optional double max_value = 4; |
| 56 | + |
| 57 | + /* |
| 58 | + * Human-facing unit label for the value (e.g. "m", "s", "dBm"). |
| 59 | + */ |
| 60 | + optional string unit = 5; |
| 61 | +} |
| 62 | + |
| 63 | +extend google.protobuf.FieldOptions { |
| 64 | + /* |
| 65 | + * Attach FieldMetadata to a field, e.g. |
| 66 | + * uint32 rx_gpio = 8 [(meshtastic.field_metadata) = { diy_only: true }]; |
| 67 | + * |
| 68 | + * Private-use extension number range is 50000-99999. |
| 69 | + */ |
| 70 | + optional FieldMetadata field_metadata = 51001; |
| 71 | +} |
0 commit comments