aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2018-07-27 13:25:00 -0700
committerandroid-build-merger <android-build-merger@google.com>2018-07-27 13:25:00 -0700
commit8863e422936e9dcd96ef75db8e7d735884b16787 (patch)
treec28e65883c2587f3f19a80e40020ad89ba49dabd /examples
parent85687fde93fe54eccfd3b20bac9ca7883ffb612a (diff)
parent731c7139ab46dd0c22bcbda506069e5454e9b2c2 (diff)
downloadnanopb-c-8863e422936e9dcd96ef75db8e7d735884b16787.tar.gz
Revert "Upgrade nanopb to 0.3.9.1" am: 72d4ea3f96
am: 731c7139ab Change-Id: I90a1a47afc2a7bb17ef2f35c8a33963cc169174a
Diffstat (limited to 'examples')
-rw-r--r--examples/cmake_relpath/CMakeLists.txt18
-rw-r--r--examples/cmake_relpath/README.txt18
-rw-r--r--examples/cmake_relpath/proto/simple.proto11
-rw-r--r--examples/cmake_relpath/proto/sub/unlucky.proto5
-rw-r--r--examples/cmake_relpath/simple.c73
-rw-r--r--examples/cmake_simple/CMakeLists.txt16
-rw-r--r--examples/cmake_simple/README.txt18
-rw-r--r--examples/cmake_simple/simple.c71
-rw-r--r--examples/cmake_simple/simple.proto9
-rw-r--r--examples/network_server/client.c96
-rw-r--r--examples/network_server/fileproto.proto2
-rw-r--r--examples/network_server/server.c89
-rw-r--r--examples/simple/Makefile1
-rw-r--r--examples/simple/rules.mk24
-rw-r--r--examples/simple/simple.c11
-rw-r--r--examples/simple/simple.pb.c19
-rw-r--r--examples/simple/simple.pb.h51
-rw-r--r--examples/simple/simple.proto2
-rw-r--r--examples/using_double_on_avr/doubleproto.proto2
-rw-r--r--examples/using_union_messages/README.txt3
-rw-r--r--examples/using_union_messages/unionproto.proto2
21 files changed, 70 insertions, 471 deletions
diff --git a/examples/cmake_relpath/CMakeLists.txt b/examples/cmake_relpath/CMakeLists.txt
deleted file mode 100644
index e7727d8..0000000
--- a/examples/cmake_relpath/CMakeLists.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-project(NANOPB_CMAKE_SIMPLE C)
-
-set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../extra)
-find_package(Nanopb REQUIRED)
-include_directories(${NANOPB_INCLUDE_DIRS})
-
-nanopb_generate_cpp(PROTO_SRCS PROTO_HDRS RELPATH proto
- proto/simple.proto proto/sub/unlucky.proto)
-
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-#add_custom_target(generate_proto_sources DEPENDS ${PROTO_SRCS} ${PROTO_HDRS})
-set_source_files_properties(${PROTO_SRCS} ${PROTO_HDRS}
- PROPERTIES GENERATED TRUE)
-
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -g -O0")
-
-add_executable(simple simple.c ${PROTO_SRCS} ${PROTO_HDRS})
diff --git a/examples/cmake_relpath/README.txt b/examples/cmake_relpath/README.txt
deleted file mode 100644
index aa0f3f3..0000000
--- a/examples/cmake_relpath/README.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-Nanopb example "simple" using CMake
-=======================
-
-This example is the same as the simple nanopb example but built using CMake.
-
-Example usage
--------------
-
-On Linux, create a build directory and then call cmake:
-
- nanopb/examples/cmake_simple$ mkdir build
- nanopb/examples/cmake_simple$ cd build/
- nanopb/examples/cmake_simple/build$ cmake ..
- nanopb/examples/cmake_simple/build$ make
-
-After that, you can run it with the command: ./simple
-
-On other platforms supported by CMake, refer to CMake instructions.
diff --git a/examples/cmake_relpath/proto/simple.proto b/examples/cmake_relpath/proto/simple.proto
deleted file mode 100644
index 3bf4ad1..0000000
--- a/examples/cmake_relpath/proto/simple.proto
+++ /dev/null
@@ -1,11 +0,0 @@
-// A very simple protocol definition, consisting of only
-// one message.
-syntax = "proto2";
-
-import "sub/unlucky.proto";
-
-message SimpleMessage {
- required int32 lucky_number = 1;
- required UnluckyNumber unlucky = 2;
-}
-
diff --git a/examples/cmake_relpath/proto/sub/unlucky.proto b/examples/cmake_relpath/proto/sub/unlucky.proto
deleted file mode 100644
index 97a42c9..0000000
--- a/examples/cmake_relpath/proto/sub/unlucky.proto
+++ /dev/null
@@ -1,5 +0,0 @@
-syntax = "proto2";
-
-message UnluckyNumber {
- required uint32 number = 1;
-}
diff --git a/examples/cmake_relpath/simple.c b/examples/cmake_relpath/simple.c
deleted file mode 100644
index 231886c..0000000
--- a/examples/cmake_relpath/simple.c
+++ /dev/null
@@ -1,73 +0,0 @@
-#include <stdio.h>
-#include <pb_encode.h>
-#include <pb_decode.h>
-#include "simple.pb.h"
-
-int main()
-{
- /* This is the buffer where we will store our message. */
- uint8_t buffer[128];
- size_t message_length;
- bool status;
-
- /* Encode our message */
- {
- /* Allocate space on the stack to store the message data.
- *
- * Nanopb generates simple struct definitions for all the messages.
- * - check out the contents of simple.pb.h!
- * It is a good idea to always initialize your structures
- * so that you do not have garbage data from RAM in there.
- */
- SimpleMessage message = SimpleMessage_init_zero;
-
- /* Create a stream that will write to our buffer. */
- pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer));
-
- /* Fill in the lucky number */
- message.lucky_number = 13;
- message.unlucky.number = 42;
-
- /* Now we are ready to encode the message! */
- status = pb_encode(&stream, SimpleMessage_fields, &message);
- message_length = stream.bytes_written;
-
- /* Then just check for any errors.. */
- if (!status)
- {
- printf("Encoding failed: %s\n", PB_GET_ERROR(&stream));
- return 1;
- }
- }
-
- /* Now we could transmit the message over network, store it in a file or
- * wrap it to a pigeon's leg.
- */
-
- /* But because we are lazy, we will just decode it immediately. */
-
- {
- /* Allocate space for the decoded message. */
- SimpleMessage message = SimpleMessage_init_zero;
-
- /* Create a stream that reads from the buffer. */
- pb_istream_t stream = pb_istream_from_buffer(buffer, message_length);
-
- /* Now we are ready to decode the message. */
- status = pb_decode(&stream, SimpleMessage_fields, &message);
-
- /* Check for errors... */
- if (!status)
- {
- printf("Decoding failed: %s\n", PB_GET_ERROR(&stream));
- return 1;
- }
-
- /* Print the data contained in the message. */
- printf("Your lucky number was %d!\n", message.lucky_number);
- printf("Your unlucky number was %u!\n", message.unlucky.number);
- }
-
- return 0;
-}
-
diff --git a/examples/cmake_simple/CMakeLists.txt b/examples/cmake_simple/CMakeLists.txt
deleted file mode 100644
index e5f33a0..0000000
--- a/examples/cmake_simple/CMakeLists.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-project(NANOPB_CMAKE_SIMPLE C)
-
-set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../extra)
-find_package(Nanopb REQUIRED)
-include_directories(${NANOPB_INCLUDE_DIRS})
-
-nanopb_generate_cpp(PROTO_SRCS PROTO_HDRS simple.proto)
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-#add_custom_target(generate_proto_sources DEPENDS ${PROTO_SRCS} ${PROTO_HDRS})
-set_source_files_properties(${PROTO_SRCS} ${PROTO_HDRS}
- PROPERTIES GENERATED TRUE)
-
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -g -O0")
-
-add_executable(simple simple.c ${PROTO_SRCS} ${PROTO_HDRS})
diff --git a/examples/cmake_simple/README.txt b/examples/cmake_simple/README.txt
deleted file mode 100644
index aa0f3f3..0000000
--- a/examples/cmake_simple/README.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-Nanopb example "simple" using CMake
-=======================
-
-This example is the same as the simple nanopb example but built using CMake.
-
-Example usage
--------------
-
-On Linux, create a build directory and then call cmake:
-
- nanopb/examples/cmake_simple$ mkdir build
- nanopb/examples/cmake_simple$ cd build/
- nanopb/examples/cmake_simple/build$ cmake ..
- nanopb/examples/cmake_simple/build$ make
-
-After that, you can run it with the command: ./simple
-
-On other platforms supported by CMake, refer to CMake instructions.
diff --git a/examples/cmake_simple/simple.c b/examples/cmake_simple/simple.c
deleted file mode 100644
index 1f6b137..0000000
--- a/examples/cmake_simple/simple.c
+++ /dev/null
@@ -1,71 +0,0 @@
-#include <stdio.h>
-#include <pb_encode.h>
-#include <pb_decode.h>
-#include "simple.pb.h"
-
-int main()
-{
- /* This is the buffer where we will store our message. */
- uint8_t buffer[128];
- size_t message_length;
- bool status;
-
- /* Encode our message */
- {
- /* Allocate space on the stack to store the message data.
- *
- * Nanopb generates simple struct definitions for all the messages.
- * - check out the contents of simple.pb.h!
- * It is a good idea to always initialize your structures
- * so that you do not have garbage data from RAM in there.
- */
- SimpleMessage message = SimpleMessage_init_zero;
-
- /* Create a stream that will write to our buffer. */
- pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer));
-
- /* Fill in the lucky number */
- message.lucky_number = 13;
-
- /* Now we are ready to encode the message! */
- status = pb_encode(&stream, SimpleMessage_fields, &message);
- message_length = stream.bytes_written;
-
- /* Then just check for any errors.. */
- if (!status)
- {
- printf("Encoding failed: %s\n", PB_GET_ERROR(&stream));
- return 1;
- }
- }
-
- /* Now we could transmit the message over network, store it in a file or
- * wrap it to a pigeon's leg.
- */
-
- /* But because we are lazy, we will just decode it immediately. */
-
- {
- /* Allocate space for the decoded message. */
- SimpleMessage message = SimpleMessage_init_zero;
-
- /* Create a stream that reads from the buffer. */
- pb_istream_t stream = pb_istream_from_buffer(buffer, message_length);
-
- /* Now we are ready to decode the message. */
- status = pb_decode(&stream, SimpleMessage_fields, &message);
-
- /* Check for errors... */
- if (!status)
- {
- printf("Decoding failed: %s\n", PB_GET_ERROR(&stream));
- return 1;
- }
-
- /* Print the data contained in the message. */
- printf("Your lucky number was %d!\n", message.lucky_number);
- }
-
- return 0;
-}
-
diff --git a/examples/cmake_simple/simple.proto b/examples/cmake_simple/simple.proto
deleted file mode 100644
index 5c73a3b..0000000
--- a/examples/cmake_simple/simple.proto
+++ /dev/null
@@ -1,9 +0,0 @@
-// A very simple protocol definition, consisting of only
-// one message.
-
-syntax = "proto2";
-
-message SimpleMessage {
- required int32 lucky_number = 1;
-}
-
diff --git a/examples/network_server/client.c b/examples/network_server/client.c
index ca0c68e..e6e9a2e 100644
--- a/examples/network_server/client.c
+++ b/examples/network_server/client.c
@@ -23,13 +23,9 @@
#include "fileproto.pb.h"
#include "common.h"
-/* This callback function will be called once for each filename received
- * from the server. The filenames will be printed out immediately, so that
- * no memory has to be allocated for them.
- */
bool printfile_callback(pb_istream_t *stream, const pb_field_t *field, void **arg)
{
- FileInfo fileinfo = {};
+ FileInfo fileinfo;
if (!pb_decode(stream, FileInfo_fields, &fileinfo))
return false;
@@ -39,66 +35,51 @@ bool printfile_callback(pb_istream_t *stream, const pb_field_t *field, void **ar
return true;
}
-/* This function sends a request to socket 'fd' to list the files in
- * directory given in 'path'. The results received from server will
- * be printed to stdout.
- */
bool listdir(int fd, char *path)
{
- /* Construct and send the request to server */
+ ListFilesRequest request;
+ ListFilesResponse response;
+ pb_istream_t input = pb_istream_from_socket(fd);
+ pb_ostream_t output = pb_ostream_from_socket(fd);
+ uint8_t zero = 0;
+
+ if (path == NULL)
{
- ListFilesRequest request = {};
- pb_ostream_t output = pb_ostream_from_socket(fd);
-
- /* In our protocol, path is optional. If it is not given,
- * the server will list the root directory. */
- if (path == NULL)
- {
- request.has_path = false;
- }
- else
- {
- request.has_path = true;
- if (strlen(path) + 1 > sizeof(request.path))
- {
- fprintf(stderr, "Too long path.\n");
- return false;
- }
-
- strcpy(request.path, path);
- }
-
- /* Encode the request. It is written to the socket immediately
- * through our custom stream. */
- if (!pb_encode_delimited(&output, ListFilesRequest_fields, &request))
- {
- fprintf(stderr, "Encoding failed: %s\n", PB_GET_ERROR(&output));
- return false;
- }
+ request.has_path = false;
}
-
- /* Read back the response from server */
+ else
{
- ListFilesResponse response = {};
- pb_istream_t input = pb_istream_from_socket(fd);
-
- /* Give a pointer to our callback function, which will handle the
- * filenames as they arrive. */
- response.file.funcs.decode = &printfile_callback;
-
- if (!pb_decode_delimited(&input, ListFilesResponse_fields, &response))
+ request.has_path = true;
+ if (strlen(path) + 1 > sizeof(request.path))
{
- fprintf(stderr, "Decode failed: %s\n", PB_GET_ERROR(&input));
+ fprintf(stderr, "Too long path.\n");
return false;
}
- /* If the message from server decodes properly, but directory was
- * not found on server side, we get path_error == true. */
- if (response.path_error)
- {
- fprintf(stderr, "Server reported error.\n");
- return false;
- }
+ strcpy(request.path, path);
+ }
+
+ if (!pb_encode(&output, ListFilesRequest_fields, &request))
+ {
+ fprintf(stderr, "Encoding failed.\n");
+ return false;
+ }
+
+ /* We signal the end of request with a 0 tag. */
+ pb_write(&output, &zero, 1);
+
+ response.file.funcs.decode = &printfile_callback;
+
+ if (!pb_decode(&input, ListFilesResponse_fields, &response))
+ {
+ fprintf(stderr, "Decode failed: %s\n", PB_GET_ERROR(&input));
+ return false;
+ }
+
+ if (response.path_error)
+ {
+ fprintf(stderr, "Server reported error.\n");
+ return false;
}
return true;
@@ -115,7 +96,6 @@ int main(int argc, char **argv)
sockfd = socket(AF_INET, SOCK_STREAM, 0);
- /* Connect to server running on localhost:1234 */
memset(&servaddr, 0, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
@@ -127,11 +107,9 @@ int main(int argc, char **argv)
return 1;
}
- /* Send the directory listing request */
if (!listdir(sockfd, path))
return 2;
- /* Close connection */
close(sockfd);
return 0;
diff --git a/examples/network_server/fileproto.proto b/examples/network_server/fileproto.proto
index 5640b8d..3e70c49 100644
--- a/examples/network_server/fileproto.proto
+++ b/examples/network_server/fileproto.proto
@@ -2,8 +2,6 @@
//
// See also the nanopb-specific options in fileproto.options.
-syntax = "proto2";
-
message ListFilesRequest {
optional string path = 1 [default = "/"];
}
diff --git a/examples/network_server/server.c b/examples/network_server/server.c
index f500dcd..9a9c264 100644
--- a/examples/network_server/server.c
+++ b/examples/network_server/server.c
@@ -23,16 +23,11 @@
#include "fileproto.pb.h"
#include "common.h"
-/* This callback function will be called once during the encoding.
- * It will write out any number of FileInfo entries, without consuming unnecessary memory.
- * This is accomplished by fetching the filenames one at a time and encoding them
- * immediately.
- */
bool listdir_callback(pb_ostream_t *stream, const pb_field_t *field, void * const *arg)
{
DIR *dir = (DIR*) *arg;
struct dirent *file;
- FileInfo fileinfo = {};
+ FileInfo fileinfo;
while ((file = readdir(dir)) != NULL)
{
@@ -40,76 +35,53 @@ bool listdir_callback(pb_ostream_t *stream, const pb_field_t *field, void * cons
strncpy(fileinfo.name, file->d_name, sizeof(fileinfo.name));
fileinfo.name[sizeof(fileinfo.name) - 1] = '\0';
- /* This encodes the header for the field, based on the constant info
- * from pb_field_t. */
if (!pb_encode_tag_for_field(stream, field))
return false;
- /* This encodes the data for the field, based on our FileInfo structure. */
if (!pb_encode_submessage(stream, FileInfo_fields, &fileinfo))
return false;
}
- /* Because the main program uses pb_encode_delimited(), this callback will be
- * called twice. Rewind the directory for the next call. */
- rewinddir(dir);
-
return true;
}
-/* Handle one arriving client connection.
- * Clients are expected to send a ListFilesRequest, terminated by a '0'.
- * Server will respond with a ListFilesResponse message.
- */
void handle_connection(int connfd)
{
- DIR *directory = NULL;
+ ListFilesRequest request;
+ ListFilesResponse response;
+ pb_istream_t input = pb_istream_from_socket(connfd);
+ pb_ostream_t output = pb_ostream_from_socket(connfd);
+ DIR *directory;
- /* Decode the message from the client and open the requested directory. */
+ if (!pb_decode(&input, ListFilesRequest_fields, &request))
{
- ListFilesRequest request = {};
- pb_istream_t input = pb_istream_from_socket(connfd);
-
- if (!pb_decode_delimited(&input, ListFilesRequest_fields, &request))
- {
- printf("Decode failed: %s\n", PB_GET_ERROR(&input));
- return;
- }
-
- directory = opendir(request.path);
- printf("Listing directory: %s\n", request.path);
+ printf("Decode failed: %s\n", PB_GET_ERROR(&input));
+ return;
}
- /* List the files in the directory and transmit the response to client */
+ directory = opendir(request.path);
+
+ printf("Listing directory: %s\n", request.path);
+
+ if (directory == NULL)
{
- ListFilesResponse response = {};
- pb_ostream_t output = pb_ostream_from_socket(connfd);
-
- if (directory == NULL)
- {
- perror("opendir");
-
- /* Directory was not found, transmit error status */
- response.has_path_error = true;
- response.path_error = true;
- response.file.funcs.encode = NULL;
- }
- else
- {
- /* Directory was found, transmit filenames */
- response.has_path_error = false;
- response.file.funcs.encode = &listdir_callback;
- response.file.arg = directory;
- }
+ perror("opendir");
- if (!pb_encode_delimited(&output, ListFilesResponse_fields, &response))
- {
- printf("Encoding failed: %s\n", PB_GET_ERROR(&output));
- }
+ response.has_path_error = true;
+ response.path_error = true;
+ response.file.funcs.encode = NULL;
+ }
+ else
+ {
+ response.has_path_error = false;
+ response.file.funcs.encode = &listdir_callback;
+ response.file.arg = directory;
}
- if (directory != NULL)
- closedir(directory);
+ if (!pb_encode(&output, ListFilesResponse_fields, &response))
+ {
+ printf("Encoding failed.\n");
+ }
}
int main(int argc, char **argv)
@@ -118,8 +90,8 @@ int main(int argc, char **argv)
struct sockaddr_in servaddr;
int reuse = 1;
- /* Listen on localhost:1234 for TCP connections */
listenfd = socket(AF_INET, SOCK_STREAM, 0);
+
setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse));
memset(&servaddr, 0, sizeof(servaddr));
@@ -140,7 +112,6 @@ int main(int argc, char **argv)
for(;;)
{
- /* Wait for a client */
connfd = accept(listenfd, NULL, NULL);
if (connfd < 0)
@@ -157,6 +128,4 @@ int main(int argc, char **argv)
close(connfd);
}
-
- return 0;
}
diff --git a/examples/simple/Makefile b/examples/simple/Makefile
index 970a865..02a4c3f 100644
--- a/examples/simple/Makefile
+++ b/examples/simple/Makefile
@@ -10,7 +10,6 @@ CSRC = simple.c # The main program
CSRC += simple.pb.c # The compiled protocol definition
CSRC += $(NANOPB_DIR)/pb_encode.c # The nanopb encoder
CSRC += $(NANOPB_DIR)/pb_decode.c # The nanopb decoder
-CSRC += $(NANOPB_DIR)/pb_common.c # The nanopb common parts
# Build rule for the main program
simple: $(CSRC)
diff --git a/examples/simple/rules.mk b/examples/simple/rules.mk
deleted file mode 100644
index 1e4221d..0000000
--- a/examples/simple/rules.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-NANOPB_DIR := external/nanopb-0.3.9.1-linux-x86
-
-LOCAL_DIR := $(GET_LOCAL_DIR)
-
-MODULE := $(LOCAL_DIR)
-
-MODULE_SRCS += \
- $(LOCAL_DIR)/simple.c \
- $(LOCAL_DIR)/simple.pb.c \
- $(NANOPB_DIR)/pb_encode.c \
- $(NANOPB_DIR)/pb_decode.c \
- $(NANOPB_DIR)/pb_common.c
-
-MODULE_CPPFLAGS += -std=c++11
-
-MODULE_INCLUDES += \
- $(NANOPB_DIR)
-
-$(LOCAL_DIR)/simple.pb.c: $(LOCAL_DIR)/simple.proto
- $(PROTOC) $(PROTOC_OPTS) --nanopb_out=$(LOCAL_DIR) $(LOCAL_DIR)/simple.proto
-
-include $(NANOPB_DIR)/extra/nanopb.mk
-include make/module.mk
-
diff --git a/examples/simple/simple.c b/examples/simple/simple.c
index c16ec52..3127230 100644
--- a/examples/simple/simple.c
+++ b/examples/simple/simple.c
@@ -15,11 +15,8 @@ int main()
/* Allocate space on the stack to store the message data.
*
* Nanopb generates simple struct definitions for all the messages.
- * - check out the contents of simple.pb.h!
- * It is a good idea to always initialize your structures
- * so that you do not have garbage data from RAM in there.
- */
- SimpleMessage message = SimpleMessage_init_zero;
+ * - check out the contents of simple.pb.h! */
+ SimpleMessage message;
/* Create a stream that will write to our buffer. */
pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer));
@@ -47,7 +44,7 @@ int main()
{
/* Allocate space for the decoded message. */
- SimpleMessage message = SimpleMessage_init_zero;
+ SimpleMessage message;
/* Create a stream that reads from the buffer. */
pb_istream_t stream = pb_istream_from_buffer(buffer, message_length);
@@ -63,7 +60,7 @@ int main()
}
/* Print the data contained in the message. */
- printf("Your lucky number was %d!\n", (int)message.lucky_number);
+ printf("Your lucky number was %d!\n", message.lucky_number);
}
return 0;
diff --git a/examples/simple/simple.pb.c b/examples/simple/simple.pb.c
deleted file mode 100644
index 481aa7d..0000000
--- a/examples/simple/simple.pb.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Automatically generated nanopb constant definitions */
-/* Generated by nanopb-0.3.9.1 at Fri May 25 16:28:54 2018. */
-
-#include "simple.pb.h"
-
-/* @@protoc_insertion_point(includes) */
-#if PB_PROTO_HEADER_VERSION != 30
-#error Regenerate this file with the current version of nanopb generator.
-#endif
-
-
-
-const pb_field_t SimpleMessage_fields[2] = {
- PB_FIELD( 1, INT32 , REQUIRED, STATIC , FIRST, SimpleMessage, lucky_number, lucky_number, 0),
- PB_LAST_FIELD
-};
-
-
-/* @@protoc_insertion_point(eof) */
diff --git a/examples/simple/simple.pb.h b/examples/simple/simple.pb.h
deleted file mode 100644
index f4614db..0000000
--- a/examples/simple/simple.pb.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Automatically generated nanopb header */
-/* Generated by nanopb-0.3.9.1 at Fri May 25 16:28:54 2018. */
-
-#ifndef PB_SIMPLE_PB_H_INCLUDED
-#define PB_SIMPLE_PB_H_INCLUDED
-#include <pb.h>
-
-/* @@protoc_insertion_point(includes) */
-#if PB_PROTO_HEADER_VERSION != 30
-#error Regenerate this file with the current version of nanopb generator.
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Struct definitions */
-typedef struct _SimpleMessage {
- int32_t lucky_number;
-/* @@protoc_insertion_point(struct:SimpleMessage) */
-} SimpleMessage;
-
-/* Default values for struct fields */
-
-/* Initializer values for message structs */
-#define SimpleMessage_init_default {0}
-#define SimpleMessage_init_zero {0}
-
-/* Field tags (for use in manual encoding/decoding) */
-#define SimpleMessage_lucky_number_tag 1
-
-/* Struct field encoding specification for nanopb */
-extern const pb_field_t SimpleMessage_fields[2];
-
-/* Maximum encoded size of messages (where known) */
-#define SimpleMessage_size 11
-
-/* Message IDs (where set with "msgid" option) */
-#ifdef PB_MSGID
-
-#define SIMPLE_MESSAGES \
-
-
-#endif
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-/* @@protoc_insertion_point(eof) */
-
-#endif
diff --git a/examples/simple/simple.proto b/examples/simple/simple.proto
index 5c73a3b..26e72f4 100644
--- a/examples/simple/simple.proto
+++ b/examples/simple/simple.proto
@@ -1,8 +1,6 @@
// A very simple protocol definition, consisting of only
// one message.
-syntax = "proto2";
-
message SimpleMessage {
required int32 lucky_number = 1;
}
diff --git a/examples/using_double_on_avr/doubleproto.proto b/examples/using_double_on_avr/doubleproto.proto
index 72d3f9c..d8b7f2d 100644
--- a/examples/using_double_on_avr/doubleproto.proto
+++ b/examples/using_double_on_avr/doubleproto.proto
@@ -1,6 +1,4 @@
// A message containing doubles, as used by other applications.
-syntax = "proto2";
-
message DoubleMessage {
required double field1 = 1;
required double field2 = 2;
diff --git a/examples/using_union_messages/README.txt b/examples/using_union_messages/README.txt
index d4b7fd2..7a1e75d 100644
--- a/examples/using_union_messages/README.txt
+++ b/examples/using_union_messages/README.txt
@@ -17,9 +17,6 @@ we actually want. Similarly when decoding, we can manually read the tag of
the top level message, and only then allocate the memory for the submessage
after we already know its type.
-NOTE: There is a newer protobuf feature called `oneof` that is also supported
-by nanopb. It might be a better option for new code.
-
Example usage
-------------
diff --git a/examples/using_union_messages/unionproto.proto b/examples/using_union_messages/unionproto.proto
index 209df0d..d7c9de2 100644
--- a/examples/using_union_messages/unionproto.proto
+++ b/examples/using_union_messages/unionproto.proto
@@ -5,8 +5,6 @@
// but they are commonly implemented by filling out exactly one of
// several optional fields.
-syntax = "proto2";
-
message MsgType1
{
required int32 value = 1;