Using of "bytes" type

19 views
Skip to first unread message

Alexis Lecoq

unread,
Dec 24, 2023, 1:12:28 AM12/24/23
to nanopb
Hello,

I'm trying to use the bytes type to transmit bytes array.

I can't find how to fill it.

in my .proto :

message TAG_REPORT_TYPE {
    optional bytes TID = 1;
}

what i'm trying and don't work :

tagReport.TID[0] = 0x00;
tagReport.TID[1] = 0x01;

Thanks !

Petteri Aimonen

unread,
Dec 24, 2023, 1:17:32 AM12/24/23
to nan...@googlegroups.com
Hi,

> I'm trying to use the bytes type to transmit bytes array.
> I can't find how to fill it.
>
> message TAG_REPORT_TYPE {
> optional bytes TID = 1;
> }

You'll need to specify max_size option for it in either .proto file
or in a separate .options file. After that it will give an array that
you can fill with:

tagReport.has_TID = true;
tagReport.TID.size = 1;
tagReport.TID.bytes[0] = 0x00;

--
Petteri

Reply all
Reply to author
Forward
0 new messages