|
ndn-embeds 0.1.0
Lightweight NDN protocol stack for embedded systems
|
#include </home/runner/work/ndn-embeds/ndn-embeds/adapters/espnow_face.hpp>
Inheritance diagram for ndn::EspNowFace:Public Member Functions | |
| EspNowFace (FaceId faceId=2) | |
| Constructor. | |
| ~EspNowFace () override | |
| Destructor. | |
| FaceId | id () const override |
| Get Face ID. | |
| Error | start () override |
| Initialize and start ESP-NOW. | |
| void | stop () override |
| Stop ESP-NOW. | |
| Error | send (const uint8_t *data, size_t len) override |
| Default send (broadcast) | |
| Error | sendTo (FaceId destFace, const uint8_t *data, size_t len) override |
| Unicast send to a specific Face. | |
| Error | broadcast (const uint8_t *data, size_t len) override |
| Broadcast send. | |
| size_t | maxPayloadSize () const override |
| Get maximum payload size. | |
| FaceId | addPeer (const uint8_t *mac) |
| Add a peer. | |
| void | removePeer (FaceId faceId) |
| Remove a peer. | |
| bool | getMacAddress (FaceId faceId, uint8_t *mac) const |
| Get MAC address from FaceId. | |
| size_t | peerCount () const |
| Get number of registered peers. | |
| void | processReceiveQueue () |
| Process receive events. | |
| void | setMacFilter (const uint8_t *mac) |
| Set MAC address filter (single MAC) | |
| void | setMacFilters (const uint8_t macs[][6], size_t count) |
| Set multiple MAC address filters. | |
| void | clearMacFilters () |
| Clear MAC address filters. | |
| bool | hasMacFilter () const |
| Check if MAC address filter is enabled. | |
Public Member Functions inherited from ndn::Face | |
| virtual | ~Face ()=default |
| Destructor. | |
| void | setPacketCallback (PacketCallback callback) |
| Set the packet receive callback. | |
Static Public Member Functions | |
| static EspNowFace * | instance () |
| Get the static instance (for callbacks) | |
Static Public Attributes | |
| static constexpr size_t | MAX_MAC_FILTERS = 4 |
| Maximum number of filter MACs. | |
Additional Inherited Members | |
Protected Member Functions inherited from ndn::Face | |
| void | onPacketReceived (FaceId faceId, const uint8_t *data, size_t len) |
| Internal handler for packet reception. | |
Protected Attributes inherited from ndn::Face | |
| PacketCallback | packetCallback_ |
| Packet receive callback. | |
ESP-NOW Face.
Face implementation that sends/receives NDN packets using ESP-NOW protocol.
Features:
Definition at line 72 of file espnow_face.hpp.
|
explicit |
Constructor.
| faceId | ID of this Face (default: 2) |
Definition at line 22 of file espnow_face.cpp.
|
override |
| FaceId ndn::EspNowFace::addPeer | ( | const uint8_t * | mac | ) |
Add a peer.
| mac | MAC address (6 bytes) |
Definition at line 166 of file espnow_face.cpp.
References ndn::currentTimeMs(), ndn::FACE_ID_INVALID, ndn::PeerInfo::faceId, ndn::PeerInfo::lastSeen, and ndn::macToFaceId().
|
overridevirtual |
Broadcast send.
Implements ndn::Face.
Definition at line 148 of file espnow_face.cpp.
References ndn::BROADCAST_MAC, and ndn::ESPNOW_MAX_PAYLOAD.
Referenced by send().
| void ndn::EspNowFace::clearMacFilters | ( | ) |
Clear MAC address filters.
Definition at line 325 of file espnow_face.cpp.
Referenced by setMacFilter(), and setMacFilters().
| bool ndn::EspNowFace::getMacAddress | ( | FaceId | faceId, |
| uint8_t * | mac | ||
| ) | const |
Get MAC address from FaceId.
| faceId | Face ID |
| mac | [out] MAC address output (6 bytes) |
Definition at line 212 of file espnow_face.cpp.
References ndn::PeerInfo::mac.
|
inline |
Check if MAC address filter is enabled.
Definition at line 199 of file espnow_face.hpp.
|
inlineoverridevirtual |
|
inlinestatic |
Get the static instance (for callbacks)
Definition at line 207 of file espnow_face.hpp.
|
inlineoverridevirtual |
Get maximum payload size.
Implements ndn::Face.
Definition at line 135 of file espnow_face.hpp.
References ndn::ESPNOW_MAX_PAYLOAD.
| size_t ndn::EspNowFace::peerCount | ( | ) | const |
Get number of registered peers.
Definition at line 221 of file espnow_face.cpp.
| void ndn::EspNowFace::processReceiveQueue | ( | ) |
Process receive events.
Dequeues packets from the receive queue and invokes callbacks. Must be called periodically from the main loop.
Definition at line 231 of file espnow_face.cpp.
| void ndn::EspNowFace::removePeer | ( | FaceId | faceId | ) |
Remove a peer.
| faceId | Face ID to remove |
Definition at line 203 of file espnow_face.cpp.
References ndn::PeerInfo::inUse, and ndn::PeerInfo::mac.
|
overridevirtual |
Default send (broadcast)
Implements ndn::Face.
Definition at line 103 of file espnow_face.cpp.
References broadcast().
Unicast send to a specific Face.
Implements ndn::Face.
Definition at line 108 of file espnow_face.cpp.
References ndn::ESPNOW_MAX_PAYLOAD, and ndn::PeerInfo::mac.
| void ndn::EspNowFace::setMacFilter | ( | const uint8_t * | mac | ) |
Set MAC address filter (single MAC)
| mac | Allowed MAC address (6 bytes), nullptr to disable filter |
When set, only packets from the specified MAC address are received.
Definition at line 297 of file espnow_face.cpp.
References clearMacFilters(), and setMacFilters().
| void ndn::EspNowFace::setMacFilters | ( | const uint8_t | macs[][6], |
| size_t | count | ||
| ) |
Set multiple MAC address filters.
| macs | Array of allowed MAC addresses (6 bytes each) |
| count | Number of MAC addresses (max MAX_MAC_FILTERS) |
When set, only packets from the specified MAC addresses are received. Used for topology control in multi-hop experiments.
Definition at line 305 of file espnow_face.cpp.
References clearMacFilters(), and MAX_MAC_FILTERS.
Referenced by setMacFilter().
|
overridevirtual |
Initialize and start ESP-NOW.
Wi-Fi must be initialized beforehand.
Implements ndn::Face.
Definition at line 38 of file espnow_face.cpp.
References ndn::BROADCAST_MAC.
|
overridevirtual |
Stop ESP-NOW.
Implements ndn::Face.
Definition at line 88 of file espnow_face.cpp.
Referenced by ~EspNowFace().
|
staticconstexpr |
Maximum number of filter MACs.
Definition at line 202 of file espnow_face.hpp.
Referenced by setMacFilters().