MOS Source Code
Loading...
Searching...
No Matches
pio_esp32_idf.c
Go to the documentation of this file.
1#include "pb_encode.h"
2#include "pb_decode.h"
3
4#include "test.h"
5
6#include "pio_without_options.pb.h"
7
8void app_main() {
9 int status = 0;
10
11 uint8_t buffer[256];
12 pb_ostream_t ostream;
13 pb_istream_t istream;
14 size_t written;
15
16 TestMessageWithoutOptions original = TestMessageWithoutOptions_init_zero;
17 original.number = 45;
18
19 ostream = pb_ostream_from_buffer(buffer, sizeof(buffer));
20
21 TEST(pb_encode(&ostream, &TestMessageWithoutOptions_msg, &original));
22
23 written = ostream.bytes_written;
24
25 istream = pb_istream_from_buffer(buffer, written);
26
27 TestMessageWithoutOptions decoded = TestMessageWithoutOptions_init_zero;
28
29 TEST(pb_decode(&istream, &TestMessageWithoutOptions_msg, &decoded));
30
31 TEST(decoded.number == 45);
32}
bool pb_decode(pb_istream_t *stream, const pb_msgdesc_t *fields, void *dest_struct)
Definition pb_decode.c:1182
pb_istream_t pb_istream_from_buffer(const pb_byte_t *buf, size_t msglen)
Definition pb_decode.c:143
pb_ostream_t pb_ostream_from_buffer(pb_byte_t *buf, size_t bufsize)
Definition pb_encode.c:63
bool pb_encode(pb_ostream_t *stream, const pb_msgdesc_t *fields, const void *src_struct)
Definition pb_encode.c:512
unsigned char uint8_t
Definition pb_syshdr.h:20
void app_main()
#define TEST(x)
Definition test.h:3
static char buffer[2048]
Definition test_printf.c:7