Code Monkey home page Code Monkey logo

nanopb-arduino's Introduction

nanopb-arduino

A simple ProtocolIO library for wrapping Arduino's Stream and Print objects into Nanopb's pb_istream_s and pb_ostream_s.

Exposes two functions that do exactly what you'd expect:

  • pb_istream_s as_pb_istream(Stream& p)
  • pb_ostream_s as_pb_ostream(Print& p)

In most cases, all you'll need is:

#include <pb_arduino.h>

pb_istream_s pb_in = as_pb_istream(Serial);
pb_ostream_s pb_out = as_pb_ostream(Serial);

and then use pb_encode(&pb_out, ...) and pb_decode(&pb_in).

This isn't restricted to Serial, and will work for any object that implements Stream, such as File (returned from SD.open and the ethernet Client.


This can be used on top of PacketIO, with

#include <pb_arduino.h>
#include <cobs/Stream.h>
#include <cobs/Print.h>

COBSStream cobs_in(Serial);
pb_istream_s pb_in = as_pb_istream(cobs_in);

COBSPrint cobs_out(Serial);
pb_ostream_s pb_out = as_pb_ostream(cobs_out);

and then calling cobs_out.end() after each pb_encode, and cobs_in.next() after each pb_decode.

nanopb-arduino's People

Contributors

eric-wieser avatar scherbatey avatar

Watchers

 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.