如何编码重复的Google.protobuf.
我有一条消息,我想将其包装成任何重复的Google Proto Type :: 有没有办法编码重复任何消息类型?
我什至可以使用google.protobuf。
message Onesensor{
string name=1
string type=2
int32_t reading=3
}
/** Any Message **/
message RepeatedAny{
repeated google.protobuf.any sensors = 1;
}
我正在寻找一个示例,目前正在使用纳米布进行编码。
I have a message and I would like to package it into an any repeated google proto type::
Is there a way to encode an repeated any message type?
Can I even use repeated tag with google.protobuf.any?
message Onesensor{
string name=1
string type=2
int32_t reading=3
}
/** Any Message **/
message RepeatedAny{
repeated google.protobuf.any sensors = 1;
}
I am looking for an example, currently using nanopb to encode.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当然,这只是一条常规消息。
https://github.com/nanapb/nanopb/nanopb/nanapb/nananopb/tree/master/master/master/master/master/master/master/master/master/master/master/master/master/master/master/master/master/master/master/master/master/tests/- Any_type 显示了如何编码单个消息,编码许多消息就像编码任何数组一样。您可以选择静态分配,动态分配或使用回调。或者,您可以一次将单个子字段编码到输出流中,因为串联编码的串联阵列以Protobuf格式进行。
Sure, it is just a regular message.
https://github.com/nanopb/nanopb/tree/master/tests/any_type shows how to encode a single Any message, encoding many is like encoding any array. You'll have a choice between allocating statically, allocating dynamically or using callbacks. Or you can just encode a single subfield at a time into output stream, because concatenating encoded concatenates arrays in protobuf format.
我想我发现了我的问题,我无法使用(在google.protobuf.any上重复标签,因为我想在最后二进制中附加 repoyedany 消息):
相反,我应该使用类似的东西:
我不应该在google.protobuf..ony上使用重复标签。 ....(Sensorsn),一个或多个 Sensorany 消息。
以下是示例代码,如果某人将来找到了这个问题,则 nanopb :
I think I found my issue, I cannot use(repeated tag on the google.protobuf.any, as I would like to append the RepeatedAny messages in the final binary):
Instead I should use something like this:
I should not use the repeated tag on the google.protobuf.any, I should be using it on a message that contains the google.protobuf.any instead, so that the protobinary can contain the format (sensors1), (sensors2).....(sensorsN), one or more SensorAny messages.
Below is the sample code, if someone finds this question in the future for nanopb: