• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// This is an example of how to handle 'union' style messages
2// with nanopb, without allocating memory for all the message types.
3//
4// There is no official type in Protocol Buffers for describing unions,
5// but they are commonly implemented by filling out exactly one of
6// several optional fields.
7
8message MsgType1
9{
10    required int32 value = 1;
11}
12
13message MsgType2
14{
15    required bool value = 1;
16}
17
18message MsgType3
19{
20    required int32 value1 = 1;
21    required int32 value2 = 2;
22}
23
24message UnionMessage
25{
26    optional MsgType1 msg1 = 1;
27    optional MsgType2 msg2 = 2;
28    optional MsgType3 msg3 = 3;
29}
30
31