88#include < variant>
99#include < vector>
1010
11+ #include < wpi/struct/Struct.h>
12+
1113namespace telemetrykit {
1214
1315/* *
@@ -75,9 +77,17 @@ class LogValue {
7577 // Constructor for struct data with type string (MUST come before bool constructor)
7678 LogValue (const std::vector<uint8_t >& data, std::string_view typeString);
7779
80+ // Constructor for struct data with type string and schema
81+ LogValue (const std::vector<uint8_t >& data, std::string_view typeString,
82+ std::span<const uint8_t > schema);
83+
7884 // Constructor for struct arrays
7985 LogValue (const std::vector<uint8_t >& data, std::string_view typeString, bool isArray);
8086
87+ // Constructor for struct arrays with schema
88+ LogValue (const std::vector<uint8_t >& data, std::string_view typeString,
89+ std::span<const uint8_t > schema, bool isArray);
90+
8191 // Constructor for raw binary data (no default parameter to avoid ambiguity)
8292 LogValue (const std::vector<uint8_t >& value, bool isStruct);
8393
@@ -151,14 +161,22 @@ class LogValue {
151161 LogType m_type;
152162 ValueVariant m_value;
153163 std::string m_typeString; // For struct types (e.g., "Pose2d")
164+ std::vector<uint8_t > m_schema; // For struct schema bytes (NT4 schema publishing)
165+
166+ public:
167+ /* *
168+ * Get the schema bytes for struct types.
169+ * Returns empty span for non-struct types.
170+ */
171+ std::span<const uint8_t > GetSchema () const { return m_schema; }
154172};
155173
156174/* *
157175 * Helper function to create a LogValue from a WPILib struct.
158176 *
159177 * Example:
160178 * frc::Pose2d pose{...};
161- * LogValue value = LogValue::FromStruct (pose);
179+ * LogValue value = MakeStructValue (pose);
162180 */
163181template <typename T>
164182LogValue MakeStructValue (const T& structValue) {
@@ -169,8 +187,11 @@ LogValue MakeStructValue(const T& structValue) {
169187 std::vector<uint8_t > buffer (descriptor.GetSize ());
170188 descriptor.Pack (buffer, structValue);
171189
172- // Create LogValue with type string
173- return LogValue (buffer, std::string (descriptor.GetTypeName ()));
190+ // Get schema bytes
191+ auto schemaBytes = wpi::GetStructSchemaBytes<T>();
192+
193+ // Create LogValue with type string and schema
194+ return LogValue (buffer, std::string (descriptor.GetTypeName ()), schemaBytes);
174195}
175196
176197/* *
@@ -188,8 +209,11 @@ LogValue MakeStructArrayValue(std::span<const T> structArray) {
188209 descriptor.Pack (slice, structArray[i]);
189210 }
190211
191- // Create LogValue with type string and array flag
192- return LogValue (buffer, std::string (descriptor.GetTypeName ()), true );
212+ // Get schema bytes
213+ auto schemaBytes = wpi::GetStructSchemaBytes<T>();
214+
215+ // Create LogValue with type string, schema, and array flag
216+ return LogValue (buffer, std::string (descriptor.GetTypeName ()), schemaBytes, true );
193217}
194218
195219} // namespace telemetrykit
0 commit comments