Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 00003 #include "pb_decode.h" 00004 #include "sample.pb.h" 00005 00006 int main() 00007 { 00008 printf("\nProtoBufTest\n"); 00009 00010 uint8_t buffer[2] = { 0x10, 0x05 }; 00011 size_t message_length = 2; 00012 00013 protocol_Sample message = protocol_Sample_init_zero; 00014 pb_istream_t stream = pb_istream_from_buffer(buffer, message_length); 00015 bool status = pb_decode(&stream, protocol_Sample_fields, &message); 00016 if (!status) { 00017 printf("Decoding failed: %s\n", PB_GET_ERROR(&stream)); 00018 exit(1); 00019 } 00020 printf("Alarm: %d\n", message.alarm); 00021 00022 exit(0); 00023 }
Generated on Sat Jul 16 2022 13:15:16 by
1.7.2