Internals

Callback functions

The LambdaPointer class is used to provide contextfull callback functions, using c++11 lambdas

template <typename Out, typename... In>
template<>
class packetio::LambdaPointer<Out(In...)>

A wrapper for storing a pointer to a lambda function, that works with captured variables.

Template Parameters
  • Out: lambda return type
  • In: lambda argument types

Public Functions

template <typename T>
LambdaPointer(T *lambda)

Create a LambdaPointer from a lambda, possibly with captures.

Parameters
  • lambda: A pointer to the lambda function. Because this a pointer, this must be allocated on the stack.

LambdaPointer(Out (*fptr)(In...))

Create a LambdaPointer from a raw function pointer.

Parameters
  • fptr: The context-less function

Out operator()(In... in)

Invoke the underlying function.

operator bool()

Determine if the reference has been initialized.

Mirror of the Arduino interface

These classes, found in _compat, allow testing on the desktop, and potentially execution on non-Arduino platforms

class Print

Lightweight mirror of the (undocumented) arduino Print class, for use on other platforms.

Subclassed by packetio::PacketPrint, Stream

Public Functions

virtual size_t write(uint8_t) = 0
size_t write(const char *str)
virtual size_t write(const uint8_t *buffer, size_t size) = 0
size_t write(const char *buffer, size_t size)
class Stream : Print

Lightweight mirror of the arduino Stream class, for use on other platforms.

Subclassed by packetio::PacketStream

Public Functions

virtual int available() = 0
virtual int read() = 0
virtual int peek() = 0
virtual void flush() = 0
Stream()
size_t readBytes(char *buffer, size_t length)
size_t readBytes(uint8_t *buffer, size_t length)