Protocol buffers 在pbtools中对重复条目进行编码

Protocol buffers 在pbtools中对重复条目进行编码,protocol-buffers,Protocol Buffers,我有一个protobuf模式,有一堆重复的结构。差不多 syntax = "proto3"; package My message TopLevel { string swVersion = 3; string reportMac = 4; string reportSsid = 6 } message Temperature { required uint64 ts = 1; required uint32 source = 3; repeated s

我有一个protobuf模式,有一堆重复的结构。差不多

syntax = "proto3";
package My

message TopLevel 
{
   string swVersion = 3;
   string reportMac = 4;
   string reportSsid = 6
}

message Temperature
{
   required uint64 ts = 1;
   required uint32 source = 3;
   repeated sint32 readings = 4;
}

message MyMessage
{
   required TopLevel topLevel = 1;
   repeated Temperature temperature = 2;
}
我用pbtools编译,得到温度和读数的结构和函数。然而,我很难弄清楚如何动态添加“温度”条目。 或者我运气不好,需要提前告诉它我有多少参赛作品。一个问题是数据是在生成时进行编码的,我不知道每个报告将包含多少数据。
我附加了生成的代码。

在添加任何项目之前需要长度。

没关系,不能附加文件。如果有助于回答问题,我会发布相关部分。