mirror of
https://github.com/google/pebble.git
synced 2025-08-25 23:17:25 -04:00
Import of the watch repository from Pebble
This commit is contained in:
commit
3b92768480
10334 changed files with 2564465 additions and 0 deletions
5
third_party/nanopb/examples/platformio/.gitignore
vendored
Normal file
5
third_party/nanopb/examples/platformio/.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
.pio/
|
||||
.idea/
|
||||
cmake-build-*/
|
||||
/CMakeLists.txt
|
||||
CMakeListsPrivate.txt
|
48
third_party/nanopb/examples/platformio/platformio.ini
vendored
Normal file
48
third_party/nanopb/examples/platformio/platformio.ini
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
;
|
||||
; You can setup `custom_nanopb_protos` `nanopb_options` vars to generate code from proto files
|
||||
;
|
||||
; Generator will use next folders:
|
||||
;
|
||||
; `$BUILD_DIR/nanopb/generated-src` - `*.pb.h` and `*.pb.c` files
|
||||
; `$BUILD_DIR/nanopb/md5` - MD5 files to track changes in source .proto/.options
|
||||
;
|
||||
; Compiled `.pb.o` files will be located under `$BUILD_DIR/nanopb/generated-build`
|
||||
;
|
||||
; Example:
|
||||
|
||||
[env:pio_with_options]
|
||||
platform = native
|
||||
lib_deps = Nanopb
|
||||
|
||||
src_filter =
|
||||
+<pio_with_options.c>
|
||||
|
||||
; All path are relative to the `$PROJECT_DIR`
|
||||
custom_nanopb_protos =
|
||||
+<proto/pio_with_options.proto>
|
||||
custom_nanopb_options =
|
||||
--error-on-unmatched
|
||||
|
||||
[env:pio_without_options]
|
||||
platform = native
|
||||
lib_deps = Nanopb
|
||||
|
||||
src_filter =
|
||||
+<pio_without_options.c>
|
||||
|
||||
; All path are relative to the `$PROJECT_DIR`
|
||||
custom_nanopb_protos =
|
||||
+<proto/pio_without_options.proto>
|
||||
|
||||
|
||||
[env:pio_esp32_idf]
|
||||
platform = espressif32
|
||||
board = firebeetle32
|
||||
framework = espidf
|
||||
lib_deps = Nanopb
|
||||
|
||||
; Warning: the 'src_filter' option cannot be used with ESP-IDF. Select source files to build in the project CMakeLists.txt file.
|
||||
; So, we specified source files in src/CMakeLists.txt
|
||||
|
||||
custom_nanopb_protos =
|
||||
+<proto/pio_without_options.proto>
|
1
third_party/nanopb/examples/platformio/proto/pio_with_options.options
vendored
Normal file
1
third_party/nanopb/examples/platformio/proto/pio_with_options.options
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
TestMessageWithOptions.str max_size:16
|
5
third_party/nanopb/examples/platformio/proto/pio_with_options.proto
vendored
Normal file
5
third_party/nanopb/examples/platformio/proto/pio_with_options.proto
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
syntax = "proto3";
|
||||
|
||||
message TestMessageWithOptions {
|
||||
string str = 1;
|
||||
}
|
5
third_party/nanopb/examples/platformio/proto/pio_without_options.proto
vendored
Normal file
5
third_party/nanopb/examples/platformio/proto/pio_without_options.proto
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
syntax = "proto3";
|
||||
|
||||
message TestMessageWithoutOptions {
|
||||
int32 number = 1;
|
||||
}
|
34
third_party/nanopb/examples/platformio/src/pio_esp32_idf.c
vendored
Normal file
34
third_party/nanopb/examples/platformio/src/pio_esp32_idf.c
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
#include "pb_encode.h"
|
||||
#include "pb_decode.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include "pio_without_options.pb.h"
|
||||
|
||||
void app_main() {
|
||||
int status = 0;
|
||||
|
||||
uint8_t buffer[256];
|
||||
pb_ostream_t ostream;
|
||||
pb_istream_t istream;
|
||||
size_t written;
|
||||
|
||||
TestMessageWithoutOptions original = TestMessageWithoutOptions_init_zero;
|
||||
original.number = 45;
|
||||
|
||||
ostream = pb_ostream_from_buffer(buffer, sizeof(buffer));
|
||||
|
||||
TEST(pb_encode(&ostream, &TestMessageWithoutOptions_msg, &original));
|
||||
|
||||
written = ostream.bytes_written;
|
||||
|
||||
istream = pb_istream_from_buffer(buffer, written);
|
||||
|
||||
TestMessageWithoutOptions decoded = TestMessageWithoutOptions_init_zero;
|
||||
|
||||
TEST(pb_decode(&istream, &TestMessageWithoutOptions_msg, &decoded));
|
||||
|
||||
TEST(decoded.number == 45);
|
||||
|
||||
return status;
|
||||
}
|
35
third_party/nanopb/examples/platformio/src/pio_with_options.c
vendored
Normal file
35
third_party/nanopb/examples/platformio/src/pio_with_options.c
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
#include "pb_encode.h"
|
||||
#include "pb_decode.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include "pio_with_options.pb.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
int status = 0;
|
||||
|
||||
uint8_t buffer[256];
|
||||
pb_ostream_t ostream;
|
||||
pb_istream_t istream;
|
||||
size_t written;
|
||||
|
||||
TestMessageWithOptions original = TestMessageWithOptions_init_zero;
|
||||
strcpy(original.str,"Hello");
|
||||
|
||||
ostream = pb_ostream_from_buffer(buffer, sizeof(buffer));
|
||||
|
||||
TEST(pb_encode(&ostream, &TestMessageWithOptions_msg, &original));
|
||||
|
||||
written = ostream.bytes_written;
|
||||
|
||||
istream = pb_istream_from_buffer(buffer, written);
|
||||
|
||||
TestMessageWithOptions decoded = TestMessageWithOptions_init_zero;
|
||||
|
||||
TEST(pb_decode(&istream, &TestMessageWithOptions_msg, &decoded));
|
||||
|
||||
TEST(strcmp(decoded.str,"Hello") == 0);
|
||||
|
||||
return status;
|
||||
}
|
35
third_party/nanopb/examples/platformio/src/pio_without_options.c
vendored
Normal file
35
third_party/nanopb/examples/platformio/src/pio_without_options.c
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
#include "pb_encode.h"
|
||||
#include "pb_decode.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include "pio_without_options.pb.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
int status = 0;
|
||||
|
||||
uint8_t buffer[256];
|
||||
pb_ostream_t ostream;
|
||||
pb_istream_t istream;
|
||||
size_t written;
|
||||
|
||||
TestMessageWithoutOptions original = TestMessageWithoutOptions_init_zero;
|
||||
original.number = 45;
|
||||
|
||||
ostream = pb_ostream_from_buffer(buffer, sizeof(buffer));
|
||||
|
||||
TEST(pb_encode(&ostream, &TestMessageWithoutOptions_msg, &original));
|
||||
|
||||
written = ostream.bytes_written;
|
||||
|
||||
istream = pb_istream_from_buffer(buffer, written);
|
||||
|
||||
TestMessageWithoutOptions decoded = TestMessageWithoutOptions_init_zero;
|
||||
|
||||
TEST(pb_decode(&istream, &TestMessageWithoutOptions_msg, &decoded));
|
||||
|
||||
TEST(decoded.number == 45);
|
||||
|
||||
return status;
|
||||
}
|
9
third_party/nanopb/examples/platformio/src/test.h
vendored
Normal file
9
third_party/nanopb/examples/platformio/src/test.h
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#define TEST(x) \
|
||||
if (!(x)) { \
|
||||
fprintf(stderr, "\033[31;1mFAILED:\033[22;39m %s:%d %s\n", __FILE__, __LINE__, #x); \
|
||||
status = 1; \
|
||||
} else { \
|
||||
printf("\033[32;1mOK:\033[22;39m %s\n", #x); \
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue