Giter VIP home page Giter VIP logo

protob-nanopb-example's Introduction

HARDWARIO Logo

HARDWARIO nanopb Protocol buffers encoder example

Travis License Twitter

This is a simple example for encoding Google Protocol buffers using nanopb C library.

Git clone

This project is using submodule for nanopb folder. Use --recursive command for clonning or use git submodule init.

Dependencies

You have to install protoc Google Protocol buffers compiler. It is internally used by nanopb.

Usage

Edit your message.proto file. Set values of your fields in main.c and run build.sh. Script rebuilds the .proto file, builds project and executes ./a.out.

Example output:

Length: 45
086410031A090801120548656C6C6F1A090801120548656C6C6F1A090801120548656C6C6F220608F60410CE09

Simple nodejs decoder

In the node_protob_decoder/ folder there is a simple decoder. You have to manually edit line containing hexadecimal message b = Buffer.from('08641003', 'hex'); and then run the script by:

cd node_protob_decoder
npm install
node main.c

Example output

<Buffer 08 64 10 03 1a 09 08 01 12 05 48 65
6c 6c 6f 1a 09 08 01 12 05 48 65 6c 6c 6f 1a
09 08 01 12 05 48 65 6c 6c 6f 22 06 08 f6 04
10 ce 09>
{
    "luminance": 100,
    "hwRevision": "PB_REV1_2",
    "inputs": [
        {
            "state": true,
            "name": "Hello"
        },
        {
            "state": true,
            "name": "Hello"
        },
        {
            "state": true,
            "name": "Hello"
        }
    ],
    "voltage": {
        "battery": 630,
        "external": 1230
    }
}

License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with ❤  by HARDWARIO s.r.o. in the heart of Europe.

protob-nanopb-example's People

Contributors

hubmartin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.