I have proto:
message TempInfo
{
optional bytes SensorAddr = 1;
optional float Temp = 2;
optional bytes SensorRawData = 3;
}
and options:
TempInfo.SensorAddr max_size:8
TempInfo.SensorRawData max_size:9
and Code:
TempInfo tempinfo;
uint8_t buffer[128];
pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer));
copyByteArray(addr,tempinfo.SensorAddr.bytes,8);
copyByteArray(data,tempinfo.SensorRawData.bytes,9);
tempinfo.Temp = tempVal;
bool status = pb_encode(&stream, TempInfo_fields, &tempinfo);
size_t message_length = stream.bytes_written;
I tried that I comment out field filling lines and looks that I can fill only one of byte array fields. All other fields cause Encoding failed: bytes size exceeded.
Even that tempinfo.Temp = tempVal; without byte array fills cause this error. tempVal is positive float.
Is this some kind arduino compatibility problem or did I do something wrong?
Looks that I must set tempinfo.SensorAddr.size = 8; manually. with sizeof(tempinfo.SensorAddr) it shows right 8 bytes but tempinfo.SensorAddr.size was something > 300.