SNMP 2.0.0
Loading...
Searching...
No Matches
SNMP::SNMP Class Reference

#include <src/SNMP.h>

Inheritance diagram for SNMP::SNMP:
[legend]
Collaboration diagram for SNMP::SNMP:
[legend]

Public Member Functions

bool begin (UDP &udp)
 Initializes network.
 
void loop ()
 Network read operation.
 
bool send (Message *message, const IPAddress ip, const uint16_t port)
 Network write operation.
 
void onMessage (Event event)
 Sets on message event user handler.
 

Private Types

using Event = void (*)(const Message*, const IPAddress, const uint16_t)
 On message event user handler type.
 

Private Member Functions

 SNMP (const uint16_t port)
 Creates an SNMP object.
 

Private Attributes

uint16_t _port = Port::SNMP
 
UDP * _udp = nullptr
 
Event _onMessage = nullptr
 

Friends

class Agent
 
class Manager
 

Detailed Description

Definition at line 32 of file SNMP.h.

Member Typedef Documentation

◆ Event

using SNMP::SNMP::Event = void (*)(const Message*, const IPAddress, const uint16_t)
private

On message event user handler type.

The sketch must define an event handler function to process incoming message.

Example

void onMessage(const SNMP::Message *message, const IPAddress remote, const uint16_t port) {
// User code here...
}
SNMP message object.
void onMessage(Event event)
Sets on message event user handler.
Definition SNMP.h:127
Parameters
messageSNMP message to process.
remoteIP address of the sender.
portUDP port of the sender.

Definition at line 50 of file SNMP.h.

Constructor & Destructor Documentation

◆ SNMP()

SNMP::SNMP::SNMP ( const uint16_t port)
inlineprivate

Creates an SNMP object.

Parameters
portUDP port.

Definition at line 137 of file SNMP.h.

Member Function Documentation

◆ begin()

bool SNMP::SNMP::begin ( UDP & udp)
inline

Initializes network.

Parameters
udpUDP client.
Returns
1 if success, 0 if failure.

Definition at line 59 of file SNMP.h.

◆ loop()

void SNMP::SNMP::loop ( )
inline

Network read operation.

Read incoming packet, parses as an SNMP message an calls user message handler.

Warning
This function must be called frequently from the sketch loop() function.

Definition at line 72 of file SNMP.h.

References SNMP::Message::parse().

◆ onMessage()

void SNMP::SNMP::onMessage ( Event event)
inline

Sets on message event user handler.

Parameters
eventEvent handler.

Definition at line 127 of file SNMP.h.

◆ send()

bool SNMP::SNMP::send ( Message * message,
const IPAddress ip,
const uint16_t port )
inline

Network write operation.

Builds message and write outgoing packet.

Parameters
messageSNMP message to send.
ipIP address to send to.
portUDP port to send to
Returns
1 if success, 0 if failure.

Definition at line 106 of file SNMP.h.

References SNMP::Message::build(), and SNMP::Message::getSize().

Friends And Related Symbol Documentation

◆ Agent

friend class Agent
friend

Definition at line 148 of file SNMP.h.

◆ Manager

friend class Manager
friend

Definition at line 149 of file SNMP.h.

Member Data Documentation

◆ _onMessage

Event SNMP::SNMP::_onMessage = nullptr
private

On message event user handler.

Definition at line 146 of file SNMP.h.

◆ _port

uint16_t SNMP::SNMP::_port = Port::SNMP
private

UDP port .

Definition at line 142 of file SNMP.h.

◆ _udp

UDP* SNMP::SNMP::_udp = nullptr
private

UDP client.

Definition at line 144 of file SNMP.h.


The documentation for this class was generated from the following file: