hello,
i am searching for my little project a example code for an SNMP Manager which provides a simple snmp get and set query in combination with a Ethernet shield.
i was searching for hours with now success. can anyone help me out? i am an arduino beginner.
Thanks
check - Google Code Archive - Long-term storage for Google Code Project Hosting. -also some threads on the forum
thanks for the answer. i already fond this as well but as i understand with my little programing skills this is for controlling the arduino with snmp i´d like to do somthing like this :
snmpget -d -v 1 -c public 192.168.0.22 0.1.3.6.1.4.1.36582.1.8 with the arduino
in other words, i would like to use the arduino to control other devices with snmp. sending a snmp get from the arduino to a satellite modem and getting the answer back from the modem. then process the received answer and sending a snmp set to the modem.
The post title is "Manager". Missed that. The above implementations are Agents and not Managers. This would mean that you wish to construct SNMP requests, send them and receive responses and parse them.
The code in at least the Cosa library could be refactored to do that. I will consider that for the next update. This is a new usecase.
Cheers!
thanks that's great. will wait for the update...
Cheers
i was able to rewrite the code by inserting an snmpget and snmpset command. i am able to send a get query and receive the answer.
in moment my oid is hard coded for testing. now i would like to use the following OID and encode it. but i do dot know how.
the oid is stored as char like this:
static char sysDescr[] PROGMEM = "1.3.6.1.4.1..247.87.0";
and need to be converted in the following format.
pdu.OID.data[0] = 43;
pdu.OID.data[1] = 6;
pdu.OID.data[2] = 1;
pdu.OID.data[3] = 4;
pdu.OID.data[4] = 1;
pdu.OID.data[5] = 129;
pdu.OID.data[6] = 119;
pdu.OID.data[7] = 87;
pdu.OID.data[8] = 0;
the first two digits are simple this is always combined 2b (43) i can hard code it. but the rest is difficult for me especially the 247 need to be converted into 2 byte in this case 129 and 119.
can anyone help me out.
thanks a lot
The OID encoding of 247 is; 128+1,247-128=129,119. Which is what you got.
The full OID 1.3.6.1.4.1.247.87.0 should be encoded as 1,3,6,1,4,1,129,119,87,0. This should be prefixed with the length of the OID which is 10.
BTW: 1.3.6.1.4.1.247 is an enterprise OID for AEG Electrocom.
Cheers!
thanks
since i just learned c++ 3 weeks ago i do not know how to encode the individual numbers from a char array between the dots.
i tried with this code the encoding but it did not work at all why? (the length is ok)
but the extracted data is wired.
static char sysDescr[] PROGMEM = "1.3.6.1.4.1.247.87.0"; // read-only (DisplayString)
int i=0;
int n=0;
int oidlength = sizeof(sysDescr); //oid length with dot
int oidleng = (oidlength-1)/2; //oid length without dot
pdu.OID.size = oidleng; // oid length to pdu
while ( i != oidlength) {
if (sysDescr*!='.'){*
_ pdu.OID.data[n] = sysDescr*;_
_ Serial <<(" OID:") << pdu.OID.data[n] <<(" OID:")<< sysDescr << endl;
n++;
}
i++;
}*_
What library are you using? Your code above is wrong as the OID is a string and you are accessing characters and not numbers. Cheers!
i am using agentuino example as it was the best for me to understand.
is it possible to convert the string into character or wise verse?
my code is Agent in utz-michael (Michael Utz) · GitHub
the snmp libraries are in the libraries folder
cheers
Yes it is possible to write that. It is not implemented in that library, libraries/Agentuino.h at master · utz-michael/libraries · GitHub
But why not write it as an uint8_t vector instead.
Cheers.
Hi,
what about of handling SNMP Traps? Is there a library to manage the incoming SNMP Traps received from other equipments?
I'm trying to have my arduino ethernet shield as a SNMP Trap Receiver and depending on the information of the trap do some kind of stuff like blinking a LED.
However, anyone knows how to do that? How can I show the received Trap in Serial Monitor, for example? Is it possible?
Thanks