Skip to content

This repository contains a demo illustrating how to use Protobuf3.

License

Notifications You must be signed in to change notification settings

MicroEJ/Demo-Protobuf3

Repository files navigation

SDK 6 Compatible

Overview

This example project shows how to use Protobuf 3 with MicroEJ.

Protobuf is a Google's mechanism for serializing structured data. Protobuf consists in:

  • a description language that describes the structure of the data.
  • a compiler that generates source code from that description.
  • a library that is used by the generated source code for the serialization. For more information about Protobuf, please refer to https://developers.google.com/protocol-buffers.

Warning: Protobuf may not be suitable for all embedded applications. The compiler can generate a lot of code, and that can have a significant impact on the ROM footprint of the application.

Project structure

  • src/main
    • java
      • Main.java: the entry point of the example.
    • proto
      • AppProto.proto: defines the data structure of the message used in this example.
      • google/protobuf/timestamp.proto: proto file provided by Google for manipulating timestamps (used by AppProto.proto).

Java files generation

When building this project, the data format classes are automatically generated by the Protobuf Compiler (protoc), from the .proto files located in src/main/proto. In this project, we use the compiler plugin com.google.protobuf:protoc-gen-javalite to generate Java Lite files. Java Lite files are smaller and more suitable to MicroEJ VEE environment. The Java files are generated in the directory build/generated/source/proto/main/javalite.

Refer to the protobuf section of the build.gradle.kts file for more details on the configuration used in this project. You may also refer to the official Protobuf Gradle plugin documentation (https://github.com/google/protobuf-gradle-plugin).

Requirements

  • MICROEJ SDK 6.

  • A VEE Port that contains:

    • EDC-1.3 or higher.

This example has been tested on:

  • IntelliJ IDEA 2023.3.3.
  • STM32F7508-DK VEE Port 2.2.0.

Usage

By default, the example will use the STM32F7508-DK VEE Port.

Refer to the Select a VEE Port documentation for more information.

Configuration

Configuration options can be found in: configuration/common.properties.

Run on simulator

In IntelliJ IDEA or Android Studio:

  • Open the Gradle tool window by clicking on the elephant icon on the right side,
  • Expand the Tasks list,
  • From the Tasks list, expand the microej list,
  • Double-click on runOnSimulator,
  • The application starts, the traces are visible in the Run view.

Alternative ways to run in simulation are described in the Run on Simulator documentation.

Run on device

Make sure to properly set up the VEE Port environment before going further. Refer to the VEE Port README for more information.

In IntelliJ IDEA or Android Studio:

  • Open the Gradle tool window by clicking on the elephant on the right side,
  • Expand the Tasks list,
  • From the Tasks list, expand the microej list,
  • Double-Click on runOnDevice.
  • The device is flashed. Use the appropriate tool to retrieve the execution traces.

Alternative ways to run on device are described in the Run on Device documentation.

Dependencies

All dependencies are retrieved transitively by gradle.

Source

N/A

Restrictions

None.


Markdown
Copyright 2020-2024 MicroEJ Corp. All rights reserved.
Use of this source code is governed by a BSD-style license that can be found with this software.

About

This repository contains a demo illustrating how to use Protobuf3.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages