Code Monkey home page Code Monkey logo

arduino_snmp's People

Contributors

0neblock avatar aquaticus avatar nourbakhsh-rad avatar shortbloke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduino_snmp's Issues

ESP8266 - wdt reset

Hello!
I use ESP-12S ESP-12S_User_Manual.pdf, Arduino IDE 1.8.11, ESP8266 core for Arduino v.2.3.0, Example - ESP_SNMP.
Co compiles, loads successfully. The console displays:

.....
Connected to MyWifi
IP address: 192.168.1.15

Next, using iReasoning MIB Browser I am sending a request .1.3.6.1.4.1.5.0 for IP 192.168.1.15 After 5-7 seconds iReasoning gives an error message,
erreg

And in the console I see this:

......
Connected to GTW
IP address: 192.168.1.15
OID: .1.3.6.1.4.1.5.0

 ets Jan  8 2013,rst cause:4, boot mode:(3,7)

wdt reset
load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
v3de0c112
~ld

Settings Arduino IDE

rrrrr

If you request a nonexistent OID

......
Connected to GTW
IP address: 192.168.1.15
OID: .1.3.6.1.4.1.5.5
OID NOT FOUND

 ets Jan  8 2013,rst cause:4, boot mode:(3,7)

wdt reset
load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
v3de0c112
~ld

the problem also recurs

P.S. I was looking for information about this error, everywhere they say that the error occurs due to poor nutrition. I power the board from a powerful Power Bank, also has all the necessary capacitors and other elements. But this does not matter, since other projects work fine on this board, the conclusion is that the problem is not in hardware.
Do you see a way to solve the problem?

transferring tables

Hello friend, does the agent support the transmission of table values over snmp?
and what will the request look like in such cases

OID response of .0.0

Hi all,

I'm trying to make my ESP8266 respond with ".0.0" to gets for .1.3.6.1.2.1.2.2.1.22.1 (ifSpecific).

snmp.addOIDHandler(".1.3.6.1.2.1.2.2.1.22.1", ".0.0"); // ifSpecific

I have tried multiple values, such as ".0.0", "0.0", ".0".

When I do an snmpwalk or an snmpget against it, I get a general error:

Error in packet  
Reason: (genError) A general failure occured  
Failed object: IF-MIB::ifSpecific.1

The corresponding Wireshark output looks like this:

    version: v2c (1)
    community: public
    data: get-response (2)
        get-response
            request-id: 1573401971
            error-status: genErr (5)
            error-index: 1
            variable-bindings: 1 item
                1.3.6.1.2.1.2.2.1.22.1: Value (Null)
                    Object Name: 1.3.6.1.2.1.2.2.1.22.1 (iso.3.6.1.2.1.2.2.1.22.1)
                    Value (Null)
    [Response To: 1]
    [Time: 0.011983000 seconds]

Here is Wireshark output from a box not using this library:

    version: v2c (1)
    community: public
    data: get-response (2)
        get-response
            request-id: 1702378746
            error-status: noError (0)
            error-index: 0
            variable-bindings: 1 item
                1.3.6.1.2.1.2.2.1.22.1: 0.0 (itu-t.0)
                    Object Name: 1.3.6.1.2.1.2.2.1.22.1 (iso.3.6.1.2.1.2.2.1.22.1)
                    Value (OID): 0.0 (itu-t.0)
    [Response To: 63]
    [Time: 0.035553000 seconds]

Thanks for your help!

addDynamicIntegerHandler usage

I need to provide a read-only changing integer so i think i need to use the addDynamicIntegerHandler.
The challenge for me is that the SNMPAgent instance is a class member and i dont know what i've to pass as GETINT_FUNC.

class MyClass
{
	private:
		int myChangingInt;
		SNMPAgent * snmp;
		int callback_test() {return myChangingInt};
		void Init()
		{
			snmp = new SNMPAgent("public", "private");
			.
			.
			.
			// the following line returns an invalid use of non-static member function 'int MyClass::callback_test()'
    			snmp->addDynamicIntegerHandler(".1.3.6.1.4.1.14.1", callback_test, true);
			.
			.
			.
		};
};

Anyone that knows how to solve it?

ESP8266 rebooting (Exception (3)) with long oid request

Hello!
I'm getting ESP8266 resetting while doing snmp get with long oid.
Example OID: 1.3.6.1.2.1.1.5.0.4.1.1.3.4.5.67.2.21.2.23.3.4.5.5.6.2.1222.3
I'm not using long oids in my application, but I connected LibreNMS in which I wanted to keep charts. During execution of Device Discovery, ESP8266 resets multiple times.
Example OID from Librenms discovery: 1.3.6.1.4.1.8072.1.3.2.3.1.2.6.100.105.115.116.114.111

Arduino_SNMP should dropping packets with long oid, but i don't know where to implement it.

Exception (3): epc1=0x40100718 epc2=0x00000000 epc3=0x00000000 excvaddr=0x400082e1 depc=0x00000000

Exception 29: StoreProhibited: A store referenced a page mapped with an attribute that does not permit stores
PC: 0x402015b0: ComplexType::addValueToList(BER_CONTAINER*) at C:\Users\x\Documents\Arduino\libraries\Arduino_SNMP-master/BER.h line 394
EXCVADDR: 0x00000004
Memory allocation of 8 bytes failed at 0x402015b0: ComplexType::addValueToList(BER_CONTAINER*) at C:\Users\x\Documents\Arduino\libraries\Arduino_SNMP-master/BER.h line 394

Decoding stack results
0x40201820: ComplexType::fromBuffer(unsigned char*) at C:\Users\x\Documents\Arduino\libraries\Arduino_SNMP-master/BER.h line 516
0x402015a0: ComplexType::addValueToList(BER_CONTAINER*) at C:\Users\x\Documents\Arduino\libraries\Arduino_SNMP-master/BER.h line 593
0x40201810: ComplexType::fromBuffer(unsigned char*) at C:\Users\x\Documents\Arduino\libraries\Arduino_SNMP-master/BER.h line 513
0x402043ec: operator new(unsigned int) at C:\Users\x\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\abi.cpp line 39
0x40201810: ComplexType::fromBuffer(unsigned char*) at C:\Users\x\Documents\Arduino\libraries\Arduino_SNMP-master/BER.h line 513
0x40201810: ComplexType::fromBuffer(unsigned char*) at C:\Users\x\Documents\Arduino\libraries\Arduino_SNMP-master/BER.h line 513
0x40201a2e: SNMPRequest::parseFrom(unsigned char*) at C:\Users\x\Documents\Arduino\libraries\Arduino_SNMP-master/SNMPRequest.h line 49
0x40202552: SNMPAgent::addIntegerHandler(char*, int*, bool, bool) at C:\Users\x\Documents\Arduino\libraries\Arduino_SNMP-master/Arduino_SNMP.h line 446
0x40201f75: SNMPAgent::receivePacket(int) at C:\Users\x\Documents\Arduino\libraries\Arduino_SNMP-master/Arduino_SNMP.h line 209
0x4020453b: optimistic_yield(uint32_t) at C:\Users\x\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\core_esp8266_main.cpp line 128
0x40202464: SNMPAgent::loop() at C:\Users\x\Documents\Arduino\libraries\Arduino_SNMP-master/Arduino_SNMP.h line 186
0x40202823: loop() at C:\Users\x\Documents\Arduino\SNMP_agent/SNMP_agent.ino line 66
0x402045fc: loop_wrapper() at C:\Users\x\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266\core_esp8266_main.cpp line 180

Best regards! Good library!

addOIDHandler

Will there be an addOIDHandler function added?
I need to return information on question 1.3.6.1.2.1.1.2.0 which requires the OID data type.

For example:
snmpget -v 1 -c public 1.3.6.1.2.1.1.2.0
iso.3.6.1.2.1.1.2.0 = OID: iso.3.6.1.4.1.14988.1

wdt reset

Hi!
Thank you for the work you did.
I have a watchdog timer on this line (using ESP12).
int length = response->serialise(_packetBuffer);
Do you have any ideas how to fix this?

Compiling on Linux

To compile on Linux, I had to change the line:

#include <UDP.h> to #include <Udp.h>

I guess it works on Windows because since Windows isn't case sensitive.

esp8266 Vscode

I would like to start by saying thank you for all the work you have done on this library, and for a complete newbie to Arduino and coding micro controllers it was nice to find something that was simple to use,

I am using the snmp_agent with an esp8266 with the arduionIDE but switching to vscode doesn't compile it. I then found this new version of the snmp_agent and was super happy to see that it is in the platformio list, but alas it seems that i can no longer use this with the esp8266, it seems that there are missing files that stop the file compiling. is this expected and do you have plans to make it work with the esp8266?

Thanks

Caleb

No reply to request to 1.0.8802.1.1.2.1.3.6.0

Other snmp daemons reply
No Such Object available on this agent at this OID
to this request, but the library does not reply.

The OID is legitimate, it's something related to lldp and at least one monitoring software is requesting it when polling snmp devices.

Issue when GoSNMP library uses the default MaxRepetitions=50

Hi
I had an issue with Arduino locking up when using the GoSNMP library doing a bulkwalk. After some testing it was found that the default MaxRepititions=50 in the GoSNMP library made the Arduino to crash. I did a simple patch in the SNMPParser.cpp

@@ -63,10 +63,6 @@
                 pass = false;
                 globalError = GEN_ERR;
             } else {
-                // These three lines are needed to make big bulkwalk possible, without memory will be thrashed and the Arduino will stop working
-                if ( request.errorIndex.maxRepititions > 10 ){
-                    request.errorIndex.maxRepititions = 10;
-                }
                 pass = handleGetBulkRequestPDU(callbacks, request.varbindList, outResponseList, request.errorStatus.nonRepeaters, request.errorIndex.maxRepititions);
                 handleStatus = SNMP_GETBULK_OCCURRED;
             }
@@ -112,4 +108,4 @@
     }

     return handleStatus;
-}
+}

For me it seems to fix the crashing issue even when MaxRepititions=50
Best regards Assar W.

Example not working

Maybe I'm just doing it wrong but I can't get the example to work "as-is".
For the ESP32_SNMP example all I manage to get is STA_DISCONNECTED in the serial monitor.
If you'd have any leads it'd be great, I'm very much a newcommer as of SNMP protocol and so I'm most likely making rooky mistakes but it's been keeping me stumped for a while now.
Thanks in advance.

Snmp agent working example

Can you advise if your agent is working on the esp32 ? I want to build a simple snmp agent that can be polled via snmp from solar winds with a few sensors and found your GitHub code. Do you have any working snmp agent examples that would support my project?

Any help or advise would be greatly appreciated!

SNMP trap

Hi
I am a novice when it comes to SNMP so maybe this is just an self induced coding problem. I have followed the example code to send a SNMP trap. I have been using my Linux machine to receive the SNMP trap send from my Arduino system.
On my Linux system I run sudo snmptrapd -f -Le -d
output will then be:
Received 76 byte packet from UDP: [192.168.2.102]:161->[192.168.2.5]:162
0000: 30 4A 02 04 00 00 00 01 04 06 70 75 62 6C 69 63 0J........public
0016: A6 3A 02 04 FB BD FF 46 02 04 00 00 00 00 02 04 .:.....F........
0032: 00 00 00 00 30 26 30 10 06 08 2B 06 01 02 01 01 ....0&0...+.....
0048: 03 00 43 04 00 00 02 A4 30 12 06 08 2B 06 01 02 ..C.....0...+...
0064: 01 01 02 00 06 06 2B CE 04 03 01 01 ......+.....

Cannot find TrapOID in TRAP2 PDU
If I change line 151 in SNMPTrap.h
OIDType* snmpTrapOID = new OIDType(".1.3.6.1.2.1.1.2.0");
to
OIDType* snmpTrapOID = new OIDType(".1.3.6.1.6.3.1.1.4.1.0");

The output from snmptrapd will than be:
Received 78 byte packet from UDP: [192.168.2.102]:161->[192.168.2.5]:162
0000: 30 4C 02 04 00 00 00 01 04 06 70 75 62 6C 69 63 0L........public
0016: A6 3C 02 04 33 71 7B 04 02 04 00 00 00 00 02 04 .<..3q{.........
0032: 00 00 00 00 30 28 30 10 06 08 2B 06 01 02 01 01 ....0(0...+.....
0048: 03 00 43 04 00 00 06 2E 30 14 06 0A 2B 06 01 06 ..C.....0...+...
0064: 03 01 01 04 01 00 06 06 2B CE 04 03 01 01 ........+.....

2022-04-13 11:37:36 [UDP: [192.168.2.102]:161->[192.168.2.5]:162]:
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (1582) 0:00:15.82 SNMPv2-MIB::snmpTrapOID.0 = OID: EISCAT-MIB::eiscat.3.1.1

So I am not really sure what the problem can be but for the moment I will use:
OIDType* snmpTrapOID = new OIDType(".1.3.6.1.6.3.1.1.4.1.0");

I am very happy to have found this library as it has served me very well.
All the best Assar W.

Float

Is there any plan to work with a variable of the float type?
addFloatHandler would be nice.

Long Form Length bug -- fix included

When this agent receives an SNMP message encoded using long form length fields (header & length longer than 2 bytes) there is an issue with the following function in the BERDecode.cpp file.

int ComplexType::fromBuffer(const uint8_t *buf, size_t max_len){}

this is a recursive routine that calls itself on each new SNMP 'STRUCTURE' message type.

When it reaches the end of said SNMP 'STRUCTURE' message segment type it returns (to itself) returning the length used by the 'STRUCTURE' segment with a return line:

return _length + 2;

It adds '2' to the _length of the STRUCTURE segment presuming the header & length field is only 2 bytes (short form lengths).
With an SNMP message using long form length fields the header & length is 4 bytes or longer, resulting in the recursive function incorrectly pointing a few bytes from the end of the last STRUCTURE segment instead of advancing correctly beyond the just parsed segment.

Every time this routine is entered on it's first line assigns the length of the header & length to a local 'j'.
Modifying the last line in this function to return

return _length + j;

instead of

return _length + 2:

appears to cure the issue and makes the SNMP_Agent work with SNMP messages encoded using long form length fields.

Work with the type "String"

While reading from OID .1.3.6.1.2.1.1.2.0 need to return text "Sensor-Unit".
My sketch:

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <Arduino_SNMP.h>

const char* ssid = "888";
const char* password = "888";

WiFiUDP udp;
SNMPAgent snmp = SNMPAgent("public");  // Starts an SMMPAgent instance with the community string 'public'

int changingNumber = 1;
int settableNumber = 0;

String sysObjectID = "Sensor-Unit";


void setup(){
    Serial.begin(115200);
    WiFi.begin(ssid, password);
    Serial.println("");

    while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
    }
    Serial.println("");
    Serial.print("Connected to ");
    Serial.println(ssid);
    Serial.print("IP address: ");
    Serial.println(WiFi.localIP());
    snmp.setUDP(&udp);
    snmp.begin();
    
    snmp.addIntegerHandler(".1.3.6.1.4.1.5.0", &changingNumber);
    snmp.addIntegerHandler(".1.3.6.1.4.1.5.1", &settableNumber, true);
//===============================================================================

    snmp.addStringHandler(".1.3.6.1.2.1.1.2.0", &sysObjectID);

//===============================================================================

    
}

void loop(){
    snmp.loop(); // must be called as often as possible
    if(snmp.setOccurred){
        Serial.printf("Number has been set to value: %i", settableNumber);
        snmp.resetSetOccurred();
    }
    changingNumber++;
}

But I get a compilation error:

no matching function for call to 'SNMPAgent::addStringHandler(const char [19], String*)'

Here is all the text from the compiler:


C:\arduino-1.8.11_ESP8266\!_FW\UPS_SNMP\UPS_SNMP.ino: In function 'void setup()':

UPS_SNMP:38:61: error: no matching function for call to 'SNMPAgent::addStringHandler(const char [19], String*)'

     snmp.addStringHandler(".1.3.6.1.2.1.1.2.0", &sysObjectID);

                                                             ^

C:\arduino-1.8.11_ESP8266\!_FW\UPS_SNMP\UPS_SNMP.ino:38:61: note: candidate is:

In file included from C:\arduino-1.8.11_ESP8266\!_FW\UPS_SNMP\UPS_SNMP.ino:3:0:

C:\arduino-1.8.11_ESP8266\libraries\Arduino_SNMP-master/Arduino_SNMP.h:403:16: note: ValueCallback* SNMPAgent::addStringHandler(char*, char**, bool, bool)

 ValueCallback* SNMPAgent::addStringHandler(char* oid, char** value, bool isSettable, bool overwritePrefix){

                ^

C:\arduino-1.8.11_ESP8266\libraries\Arduino_SNMP-master/Arduino_SNMP.h:403:16: note:   no known conversion for argument 2 from 'String*' to 'char**'

exit status 1
no matching function for call to 'SNMPAgent::addStringHandler(const char [19], String*)'

As I understand it, it is necessary to transform String to Char? How to do it right?

Support

Is there a plan when sysdescr and other parameters be supported?

typedef struct RFC1213SystemStruct { // TODO: complete this
char* sysDescr;
char* sysObjectID;
char* sysContact;
} RFC1213_list;

Trapv2PDU

Hi, Aidan!

I was trying to make the "trap" work in the Trapv2 version, but it is only working in version 1. I used the "PowerSNMP" and the "MIB Browser" to catch the traps, but only version 1 is identified. I couldn't identify the issue....or maybe I'm doing something wrong...

Thanks in advance.

SNMP traps

Hello!
How can I send SNMP-traps from my ESP8266 board via Arduino_SNMP library?

How to "Delete" a SNMPTrap object when allocated with the new SNMPTrap command

I have a trap pointer declared with

trap = new SNMPTrap("public", SNMP_VERSION_2C);

and after sending the trap I want to delete the object so it doesn't take up memory and I will be calling the new command every time I want to send one with different information. I tried just using 'delete trap;' but that is causing a stack corruption or something and the ESP32 is restarting. Should this be feasible or am I looking at it wrong?

ESP8266 v3.0 breaks library - Use 2.7.4 (or older)

When using the https://arduino.esp8266.com/stable/package_esp8266com_index.json board file for the esp8266, it is imperative to select version 2.7.4 (or older) for this library to work. Version 3.0 (and newer) causes the following output:

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (0):
epc1=0x402023e1 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffffde0 end: 3fffffc0 offset: 0190
3fffff70:  4600000a 00ffffff 0100000a 402023e1  
3fffff80:  3ffef568 3ffef588 3ffef648 40202a24  
3fffff90:  40213e58 4600000a 40212dc0 4020158c  
3fffffa0:  3fffdad0 00000000 3ffef784 4020b514  
3fffffb0:  feefeffe feefeffe 3ffe85f0 40100db1  
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3460, room 16 
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4 
tail 4
chksum 0xc9
csum 0xc9
v0006df00
~ld
Booting
Ready

OIDs greater than 127

Thanks for your awesome work!
When I'm using OID values <= 127 then FrameFlow can find all OIDs created with snmp.addStringHandler/snmp.addIntegerHandler.
But I have to use greater numbers and when I use an example sketch from another website there is the OID: ".1.3.6.1.4.1.12345.0" used and with this OID my SNMP browser only shows this OID (the first declared) and the others will not be found.

Do you have a solution for this, or have I forgotten something? I am using your actual library, downloaded here.

Thank you for your help!

addDynamicWrite ?

Hi. Since you recently added the "addDynamicReadOnly" callbacks (by the way, they are all named addDynamicReadOnly except for the integer one which is missing the "ReadOnly" part, maybe you should change that for consistency).

It would be very useful to have this but for writing variables too. Is that possible? I would like to avoid the need to duplicate the variables in my code. I would prefer to be called using a callback with the new variable value and set it myself inside my class or something.

Also, using std:: function would be very useful to have callbacks managed directly with class members instead of global functions.

Thanks!!

SNMP Manager

Hey,

I am working on adding the functionality to act as an SNMP Server or Manager. In the meantime, if you need to do this, look at the library here: https://github.com/shortbloke/Arduino_SNMP_Manager

I was going to use your updated agent library to rework the Manager, however, if this is something you're already processing with, there seems little point in me spending time on this. Can you confirm that you plan to release a manager in the near future?

Thanks Martin/Shortbloke

CORRUPT PACKET causes reboot on ESP32

Hi,

While I've successfully implemented SNMP in some of my current projects using this library and the ESP32 platform, I believe there is some kind of problem or bug related to the memory allocation/deallocation done by the library when dealing with corrupt packets in an unreliable network.

For reference, take the example ESP32_SNMP provided.

In the setup routine, add many more integer handlers (like, 20 or so). The content of the monitored variables doesn't matter, they all can be set to zero.

Also, instead of putting "snmp.loop()" in the main loop, I'm using an ESP32 task, so, in the setup routine there is the task startup.

So, boiling it down and removing everything unneeded:

#include <WiFi.h>
#include <WiFiUdp.h>
#include <Arduino_SNMP.h>

const char* ssid = "ssid";
const char* password = "password"
WiFiUDP udp;
SNMPAgent snmp = SNMPAgent("public");  // Starts an SMMPAgent instance with the community string 'public'

int changingNumber = 1;
int changingNumber1 = 1;
int changingNumber2 = 1;
int changingNumber3 = 1;
int changingNumber4 = 1;
int changingNumber5 = 1;
int changingNumber6 = 1;
int changingNumber7 = 1;
int changingNumber8 = 1;
int changingNumber9 = 1;
int changingNumber10 = 1;
int changingNumber11 = 1;


void setup(){
    Serial.begin(115200);
    WiFi.begin(ssid, password);
    Serial.println("");

    // Wait for connection
    while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
    }
    Serial.println("");
    Serial.print("Connected to ");
    Serial.println(ssid);
    Serial.print("IP address: ");
    Serial.println(WiFi.localIP());
    
    // give snmp a pointer to the UDP object
    snmp.setUDP(&udp);
    snmp.begin();
    
    snmp.addIntegerHandler(".1.3.6.1.4.1.5.0", &changingNumber);
    snmp.addIntegerHandler(".1.3.6.1.4.1.5.0.1", &changingNumber1);
    snmp.addIntegerHandler(".1.3.6.1.4.1.5.0.2", &changingNumber2);
    snmp.addIntegerHandler(".1.3.6.1.4.1.5.0.3", &changingNumber3);
    snmp.addIntegerHandler(".1.3.6.1.4.1.5.0.4", &changingNumber4);
    snmp.addIntegerHandler(".1.3.6.1.4.1.5.0.5", &changingNumber5);
    snmp.addIntegerHandler(".1.3.6.1.4.1.5.0.6", &changingNumber6);
    snmp.addIntegerHandler(".1.3.6.1.4.1.5.0.7", &changingNumber7);
    snmp.addIntegerHandler(".1.3.6.1.4.1.5.0.8", &changingNumber8);
    snmp.addIntegerHandler(".1.3.6.1.4.1.5.0.9", &changingNumber9);
    snmp.addIntegerHandler(".1.3.6.1.4.1.5.0.10", &changingNumber10);
    snmp.addIntegerHandler(".1.3.6.1.4.1.5.0.11", &changingNumber11);

    // SNMP task instead of inside the loop routine
    xTaskCreate(snmp_task, "SNMP", 4000, NULL, 1, NULL);

    // In my real project, there are many other tasks running, but so far, at least one core is able to run the task all the time.
}

void loop(){
    // NO snmp.loop() here, it's inside the task
    // snmp.loop(); // must be called as often as possible
}

void snmp_task(void * p)
{
  while (true)
  {
    snmp.loop();
    delay(1);

    // Rever returns...
  }
}

Now, what happens in unreliable networks is that many times, the NMS reports "timeout" reading the values (as expected, since it is UDP based), but some times, the ESP32 reboots. IT dumps the following:

OID: .1.3.6.1.4.1.5.0.8
CORRUPT PACKET
Guru Meditation Error: Core  1 panic'ed (InstrFetchProhibited). Exception was unhandled.
Core 1 register dump:
PC      : 0x14abba12  PS      : 0x00060c30  A0      : 0x800d4b22  A1      : 0x3ffd5030  
A2      : 0x14abba12  A3      : 0x00000000  A4      : 0x0000002b  A5      : 0x00000020  
A6      : 0x3ffd67b7  A7      : 0x0000005a  A8      : 0x800d4264  A9      : 0x3ffd5010  
A10     : 0x3ffd5878  A11     : 0x0000000e  A12     : 0x0000002b  A13     : 0x3ffbfc68  
A14     : 0x00000000  A15     : 0x00023980  SAR     : 0x00000010  EXCCAUSE: 0x00000014  
EXCVADDR: 0x14abba10  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xffffffff  

Backtrace: 0x14abba12:0x3ffd5030 0x400d4b1f:0x3ffd5050 0x400d4b83:0x3ffd50a0 0x400d4b8e:0x3ffd50c0 0x4008943d:0x3ffd50e0

Rebooting...

Other times, the error reported is "LoadProhibited" and some other times, "corrupt heap".

In a minority of cases, the "CORRUPT PACKET" message does not cause any problem.

The more reliable the network is, the problem is less pronounced, but any extended run time will eventually result in a reboot.

I also tried putting both the UDP client and the SNMPAgent instance in the ESP32's RAM using the DRAM_ATTR, to no avail.

Thanks in advance.

ip address

How to send ip address? Is there a type?

How to reuse trap and update setTrapOID() for each send

Hi,

I am using your great library to send temperature SET traps to my PC every minute when over a particular threshold and its working well.

The problem I have is that when the temperature drops below a threshold I want to send a CLEAR trap to inform my software that the threshold is no long breached. This means I need to change the originally configured:

snmp_trap->setTrapOID(new OIDType(".1.3.6.1.4.1.311.2.6.1.1"));

to

snmp_trap->setTrapOID(new OIDType(".1.3.6.1.4.1.311.2.6.2.1"));

However, if I do this using 'new' the heap reduces on each trap and eventually reaches a point where the ESP32 reboots due to an exception error.

How can I redfine the setTrapOID() without using 'new' ?

Pointer to structure for addReadWriteStringHandler results in SNMP no such object

I am trying to point the addReadWriteStringHandler() to a char array within a global structure to allow a GET and SET to be performed on it and I am having real problems getting to work.

I have tried creating a pointer to the structure and dereferencing the structure like this:

SNMPAgent * snmp;
snmp = new SNMPAgent("public", "private");

CONFIG_REG conf = new CONFIG_REG();
snmp->addReadWriteStringHandler(".1.3.6.1.4.1.38218.1.3.1.0", (char
*) (*conf).sensor_name, 40, true);

But get a SNMP not such object reply in iReasoning MIB browser.

The snmp->addReadOnlyStaticStringHandler() works okay so I am at a loss as to why it will not work ?

Arduino millis() not able to convert

Trying to add uptime for the arduino. but, i have been unable to get this value to compile.
any help would be appreciated.
-- code --
snmp.addIntegerHandler(".1.3.6.1.2.1.1.3.0", millis(), false);
-- end code --

give the following
-- error --
/Users/User/Documents/Arduino/test_udp_SNMP/test_udp_SNMP.ino: In function 'void setupSNMP()':
test_udp_SNMP:116: error: invalid conversion from 'long unsigned int' to 'int*' [-fpermissive]
snmp.addIntegerHandler(".1.3.6.1.2.1.1.3.0", millis(), false);
^
In file included from /Users/User/Documents/Arduino/test_udp_SNMP/test_udp_SNMP.ino:6:0:
Arduino_SNMP.h:414: error: initializing argument 2 of 'ValueCallback* SNMPAgent::addIntegerHandler(char*, int*, bool, bool)' [-fpermissive]
ValueCallback* SNMPAgent::addIntegerHandler(char* oid, int* value, bool isSettable, bool overwritePrefix){
^
exit status 1
invalid conversion from 'long unsigned int' to 'int*' [-fpermissive]
-- end error --

Lot of libraries missing to compile on a MEGA2560

I try to use your code on an Arduino Mega 2560 attached to an ethernet shield.
I cannot compile the project because I have a lot of libraries missing.
In VallueCallbacks.h there is
#include deque
#include algorithm
and in ber.h
#include utility
#include vector

where can I find these libraries?

thank you for your help

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.