ndn-embeds 0.1.0
Lightweight NDN protocol stack for embedded systems
Loading...
Searching...
No Matches
ndn.hpp File Reference

NDN Protocol Stack for ESP32 - Main include file. More...

#include "ndn/certificate.hpp"
#include "ndn/common.hpp"
#include "ndn/crypto.hpp"
#include "ndn/cs.hpp"
#include "ndn/data.hpp"
#include "ndn/face.hpp"
#include "ndn/fib.hpp"
#include "ndn/forwarder.hpp"
#include "ndn/interest.hpp"
#include "ndn/link.hpp"
#include "ndn/name.hpp"
#include "ndn/pit.hpp"
#include "ndn/signature.hpp"
#include "ndn/tlv.hpp"

Go to the source code of this file.

Functions

Forwarderndn::getForwarder ()
 Get the global Forwarder instance.
 
void ndn::setForwarder (Forwarder &fw)
 Register the application's Forwarder for convenience APIs.
 
Error ndn::initialize ()
 Initialize the NDN protocol stack.
 
Convenience API

Helper functions that use the global Forwarder.

Can be used when a single Forwarder is sufficient.

Error ndn::expressInterest (const Interest &interest, DataCallback onData, TimeoutCallback onTimeout=nullptr)
 Send an Interest and wait for Data.
 
Error ndn::registerPrefix (std::string_view prefix, InterestCallback callback)
 Register a prefix.
 
Error ndn::putData (const Data &data)
 Send Data.
 
void ndn::processEvents ()
 Process events.
 

Detailed Description

NDN Protocol Stack for ESP32 - Main include file.

The main header file for using the NDN protocol stack. Including this file provides access to all public APIs.

Also provides a global Forwarder instance and convenience APIs.

#include <ndn/ndn.hpp>
void app_main() {
// Initialize NDN
ndn::initialize();
// Send an Interest using the convenience API
ndn::Interest interest;
interest.setName("/sensor/temperature");
ndn::expressInterest(interest, [](const ndn::Data& data) {
// Handle received Data
});
// Event loop
while (true) {
ndn::processEvents();
vTaskDelay(pdMS_TO_TICKS(10));
}
}
NDN Data packet.
Definition data.hpp:49
NDN Interest packet.
Definition interest.hpp:50
Interest & setName(const Name &name)
Set the Name (supports method chaining)
Definition interest.cpp:13
NDN Protocol Stack for ESP32 - Main include file.

Definition in file ndn.hpp.

Function Documentation

◆ expressInterest()

Error ndn::expressInterest ( const Interest interest,
DataCallback  onData,
TimeoutCallback  onTimeout = nullptr 
)
inline

Send an Interest and wait for Data.

Parameters
interestInterest to send
onDataCallback on Data reception
onTimeoutCallback on timeout (optional)
Returns
Error::Success on success
See also
Forwarder::expressInterest()

Definition at line 98 of file ndn.hpp.

References ndn::Forwarder::expressInterest(), ndn::expressInterest(), and ndn::getForwarder().

Referenced by ndn::expressInterest().

◆ getForwarder()

Forwarder & ndn::getForwarder ( )

Get the global Forwarder instance.

Returns the Forwarder registered via setForwarder(). Must be called after setForwarder().

Returns
Reference to the registered Forwarder

Definition at line 15 of file api.cpp.

References ndn::getForwarder().

Referenced by ndn::expressInterest(), ndn::getForwarder(), ndn::processEvents(), ndn::putData(), and ndn::registerPrefix().

◆ initialize()

Error ndn::initialize ( )

Initialize the NDN protocol stack.

Lightweight initialization. The Forwarder is managed by the application; call setForwarder() to register it for convenience APIs.

Returns
Error::Success on success

Definition at line 19 of file api.cpp.

References ndn::initialize().

Referenced by ndn::initialize().

◆ processEvents()

void ndn::processEvents ( )
inline

Process events.

Must be called periodically.

See also
Forwarder::processEvents()

Definition at line 135 of file ndn.hpp.

References ndn::getForwarder(), ndn::Forwarder::processEvents(), and ndn::processEvents().

Referenced by ndn::processEvents().

◆ putData()

Error ndn::putData ( const Data data)
inline

Send Data.

Parameters
dataData to send
Returns
Error::Success on success
See also
Forwarder::putData()

Definition at line 124 of file ndn.hpp.

References ndn::getForwarder(), ndn::Forwarder::putData(), and ndn::putData().

Referenced by ndn::putData().

◆ registerPrefix()

Error ndn::registerPrefix ( std::string_view  prefix,
InterestCallback  callback 
)
inline

Register a prefix.

Parameters
prefixPrefix URI string
callbackCallback on Interest reception
Returns
Error::Success on success
See also
Forwarder::registerPrefix()

Definition at line 112 of file ndn.hpp.

References ndn::getForwarder(), ndn::Forwarder::registerPrefix(), and ndn::registerPrefix().

Referenced by ndn::registerPrefix().

◆ setForwarder()

void ndn::setForwarder ( Forwarder fw)

Register the application's Forwarder for convenience APIs.

Must be called before using expressInterest(), registerPrefix(), etc.

Parameters
fwReference to the application's Forwarder

Definition at line 11 of file api.cpp.

References ndn::setForwarder().

Referenced by ndn::setForwarder().