Arduino-SNMP Program; Getting Timed Out error while doing WALK from MIB browser

Hi,

I want to run commands Set, Get and Walk from MIB browser.

I have written a code, Set and Get are working fine but getting "Timed Out" error while running Walk command from MIB browser.

Can you please help me with my code?

Given code below is the pduReceived() function which is invoked when Set/Get/Walk command is ran from MIB browser.
If you want the full code, please find it attached in this post.

void pduReceived()
{
 SNMP_PDU pdu;
 api_status = Agentuino.requestPdu(&pdu);

 if ((pdu.type == SNMP_PDU_GET || pdu.type == SNMP_PDU_GET_NEXT || pdu.type == SNMP_PDU_SET) && pdu.error == SNMP_ERR_NO_ERROR && api_status == SNMP_API_STAT_SUCCESS )
 {
 pdu.OID.toString(oid);

 if ( pdu.type == SNMP_PDU_GET_NEXT )
 {
 char tmpOIDfs[SNMP_MAX_OID_LEN];
 if ( strcmp_P( oid, sysDescr ) == 0 )
 {
 strcpy_P ( oid, sysUpTime );
 strcpy_P ( tmpOIDfs, sysUpTime );
 pdu.OID.fromString(tmpOIDfs);
 }
 else if ( strcmp_P(oid, sysUpTime ) == 0 )
 {
 strcpy_P ( oid, sysContact );
 strcpy_P ( tmpOIDfs, sysContact );
 pdu.OID.fromString(tmpOIDfs);
 }
 else if ( strcmp_P(oid, sysContact ) == 0 )
 {
 strcpy_P ( oid, sysName );
 strcpy_P ( tmpOIDfs, sysName );
 pdu.OID.fromString(tmpOIDfs);
 }
 else if ( strcmp_P(oid, sysName ) == 0 )
 {
 strcpy_P ( oid, sysLocation );
 strcpy_P ( tmpOIDfs, sysLocation );
 pdu.OID.fromString(tmpOIDfs);
 }
 else if ( strcmp_P(oid, sysLocation ) == 0 )
 {
 strcpy_P ( oid, sysServices );
 strcpy_P ( tmpOIDfs, sysServices );
 pdu.OID.fromString(tmpOIDfs);
 }
 else if ( strcmp_P(oid, sysServices ) == 0 )
 {
 strcpy_P ( oid, RR1 );
 strcpy_P ( tmpOIDfs, RR1 );
 pdu.OID.fromString(tmpOIDfs);
 }
 else if ( strcmp_P(oid, RR1 ) == 0 )
 {
 strcpy_P ( oid, RR2 );
 strcpy_P ( tmpOIDfs, RR2 );
 pdu.OID.fromString(tmpOIDfs);
 }
 else if ( strcmp_P(oid, RR2 ) == 0 )
 {
 strcpy_P ( oid, RR3 );
 strcpy_P ( tmpOIDfs, RR3 );
 pdu.OID.fromString(tmpOIDfs);
 }
 else if ( strcmp_P(oid, RR3 ) == 0 )
 {
 strcpy_P ( oid, RR4 );
 strcpy_P ( tmpOIDfs, RR4 );
 pdu.OID.fromString(tmpOIDfs);
 }
 else if ( strcmp_P(oid, RR4 ) == 0 )
 {
 strcpy_P ( oid, "1.0" );
 }
 else
 {
 int ilen = strlen(oid);
 if ( strncmp_P(oid, sysDescr, ilen ) == 0 )
 {
 strcpy_P ( oid, sysDescr );
 strcpy_P ( tmpOIDfs, sysDescr );
 pdu.OID.fromString(tmpOIDfs);
 }
 else if ( strncmp_P(oid, sysUpTime, ilen ) == 0 )
 {
 strcpy_P ( oid, sysUpTime );
 strcpy_P ( tmpOIDfs, sysUpTime );
 pdu.OID.fromString(tmpOIDfs);
 }
 else if ( strncmp_P(oid, sysContact, ilen ) == 0 )
 {
 strcpy_P ( oid, sysContact );
 strcpy_P ( tmpOIDfs, sysContact );
 pdu.OID.fromString(tmpOIDfs);
 }
 else if ( strncmp_P(oid, sysName, ilen ) == 0 )
 {
 strcpy_P ( oid, sysName );
 strcpy_P ( tmpOIDfs, sysName );
 pdu.OID.fromString(tmpOIDfs);
 }
 else if ( strncmp_P(oid, sysLocation, ilen ) == 0 )
 {
 strcpy_P ( oid, sysLocation );
 strcpy_P ( tmpOIDfs, sysLocation );
 pdu.OID.fromString(tmpOIDfs);
 }
 else if ( strncmp_P(oid, sysServices, ilen ) == 0 )
 {
 strcpy_P ( oid, sysServices );
 strcpy_P ( tmpOIDfs, sysServices );
 pdu.OID.fromString(tmpOIDfs);
 }
 else if ( strncmp_P(oid, RR1, ilen ) == 0 )
 {
 strcpy_P ( oid, RR1 );
 strcpy_P ( tmpOIDfs, RR1 );
 pdu.OID.fromString(tmpOIDfs);
 }
 else if ( strncmp_P(oid, RR2, ilen ) == 0 )
 {
 strcpy_P ( oid, RR2 );
 strcpy_P ( tmpOIDfs, RR2 );
 pdu.OID.fromString(tmpOIDfs);
 }
 else if ( strncmp_P(oid, RR3, ilen ) == 0 )
 {
 strcpy_P ( oid, RR3 );
 strcpy_P ( tmpOIDfs, RR3 );
 pdu.OID.fromString(tmpOIDfs);
 }
 else if ( strncmp_P(oid, RR4, ilen ) == 0 )
 {
 strcpy_P ( oid, RR4 );
 strcpy_P ( tmpOIDfs, RR4 );
 pdu.OID.fromString(tmpOIDfs);
 }
 }
 }
 // End of implementation SNMP GET NEXT / WALK

 if ( strcmp_P(oid, sysDescr ) == 0 )
 {
 if ( pdu.type == SNMP_PDU_SET )
 {
 status = pdu.VALUE.decode(locDescr, strlen(locDescr));
 pdu.type = SNMP_PDU_RESPONSE;
 pdu.error = status;
 }
 else
 {
 status = pdu.VALUE.encode(SNMP_SYNTAX_OCTETS, locDescr);
 pdu.type = SNMP_PDU_RESPONSE;
 pdu.error = status;
 }
 }
 else if ( strcmp_P(oid, sysUpTime ) == 0 )
 {
 if ( pdu.type == SNMP_PDU_SET )
 {
 pdu.type = SNMP_PDU_RESPONSE;
 pdu.error = SNMP_ERR_READ_ONLY;
 }
 else
 {
 status = pdu.VALUE.encode(SNMP_SYNTAX_TIME_TICKS, locUpTime);
 pdu.type = SNMP_PDU_RESPONSE;
 pdu.error = status;
 }
 }
 else if ( strcmp_P(oid, sysName ) == 0 )
 {
 if ( pdu.type == SNMP_PDU_SET )
 {
 status = pdu.VALUE.decode(locName, strlen(locName));
 pdu.type = SNMP_PDU_RESPONSE;
 pdu.error = status;
 }
 else
 {
 status = pdu.VALUE.encode(SNMP_SYNTAX_OCTETS, locName);
 pdu.type = SNMP_PDU_RESPONSE;
 pdu.error = status;
 }
 }
 else if ( strcmp_P(oid, sysContact ) == 0 )
 {
 if ( pdu.type == SNMP_PDU_SET )
 {
 status = pdu.VALUE.decode(locContact, strlen(locContact));
 pdu.type = SNMP_PDU_RESPONSE;
 pdu.error = status;
 }
 else
 {
 status = pdu.VALUE.encode(SNMP_SYNTAX_OCTETS, locContact);
 pdu.type = SNMP_PDU_RESPONSE;
 pdu.error = status;
 }
 }
 else if ( strcmp_P(oid, sysLocation ) == 0 )
 {
 if ( pdu.type == SNMP_PDU_SET )
 {
 status = pdu.VALUE.decode(locLocation, strlen(locLocation));
 pdu.type = SNMP_PDU_RESPONSE;
 pdu.error = status;
 }
 else
 {
 status = pdu.VALUE.encode(SNMP_SYNTAX_OCTETS, locLocation);
 pdu.type = SNMP_PDU_RESPONSE;
 pdu.error = status;
 }
 }
 else if ( strcmp_P(oid, sysServices) == 0 )
 {
 if ( pdu.type == SNMP_PDU_SET )
 {
 pdu.type = SNMP_PDU_RESPONSE;
 pdu.error = SNMP_ERR_READ_ONLY;
 pdu.error = status;
 }
 else
 {
 status = pdu.VALUE.encode(SNMP_SYNTAX_INT, locServices);
 pdu.type = SNMP_PDU_RESPONSE;
 pdu.error = status;
 }
 }
 else if ( strcmp_P(oid, RR1 ) == 0 )
 {
 if ( pdu.type == SNMP_PDU_SET )
 { 
 status = pdu.VALUE.decode(relayPointer);
 if (status == 0)
 {
 relayCommand[0] = *pdu.VALUE.data;
 if (relayCommand[0] == 0)
 {
 digitalWrite(R1, LOW);
 }
 if (relayCommand[0] == 1)
 {
 digitalWrite(R1, HIGH);
 }
 }
 pdu.type = SNMP_PDU_RESPONSE;
 pdu.error = status;
 }
 else
 {
 status = pdu.VALUE.encode(SNMP_SYNTAX_INT, relayCommand[0]);
 pdu.type = SNMP_PDU_RESPONSE;
 pdu.error = status;
 }
 }
 else if ( strcmp_P(oid, RR2 ) == 0 )
 {
 if ( pdu.type == SNMP_PDU_SET )
 {
 status = pdu.VALUE.decode(relayPointer);
 if (status == 0)
 {
 relayCommand[1] = *pdu.VALUE.data;
 if (relayCommand[1] == 0)
 {
 digitalWrite(R2, LOW);
 }
 if (relayCommand[1] == 1)
 {
 digitalWrite(R2, HIGH);
 }
 }
 pdu.type = SNMP_PDU_RESPONSE;
 pdu.error = status;
 }
 else
 {
 status = pdu.VALUE.encode(SNMP_SYNTAX_INT, relayCommand[1]);
 pdu.type = SNMP_PDU_RESPONSE;
 pdu.error = status;
 }
 }
 else if ( strcmp_P(oid, RR3 ) == 0 )
 {
 if ( pdu.type == SNMP_PDU_SET )
 {
 status = pdu.VALUE.decode(relayPointer);
 if (status == 0)
 {
 relayCommand[2] = *pdu.VALUE.data;
 if (relayCommand[2] == 0)
 {
 digitalWrite(R3, LOW);
 }
 if (relayCommand[2] == 1)
 {
 digitalWrite(R3, HIGH);
 }
 }
 pdu.type = SNMP_PDU_RESPONSE;
 pdu.error = status;
 }
 else
 {
 status = pdu.VALUE.encode(SNMP_SYNTAX_INT, relayCommand[2]);
 pdu.type = SNMP_PDU_RESPONSE;
 pdu.error = status;
 }
 }
 else if ( strcmp_P(oid, RR4 ) == 0 )
 {
 if ( pdu.type == SNMP_PDU_SET )
 {
 status = pdu.VALUE.decode(relayPointer);
 if (status == 0)
 {
 relayCommand[3] = *pdu.VALUE.data;
 if (relayCommand[3] == 0)
 {
 digitalWrite(R4, LOW);
 }
 if (relayCommand[3] == 1)
 {
 digitalWrite(R4, HIGH);
 }
 }
 pdu.type = SNMP_PDU_RESPONSE;
 pdu.error = status;
 }
 else
 {
 status = pdu.VALUE.encode(SNMP_SYNTAX_INT, relayCommand[3]);
 pdu.type = SNMP_PDU_RESPONSE;
 pdu.error = status;
 }
 }
 else 
 {
 pdu.type = SNMP_PDU_RESPONSE;
 pdu.error = SNMP_ERR_NO_SUCH_NAME;
 }

 Agentuino.responsePdu(&pdu);
 }

 Agentuino.freePdu(&pdu);

}

SNMP_Test_Program.ino (12.3 KB)