SNMP Trap Invalid Parameter error?

Hello,

I have a custom board based off the MIMXRT1050-EVKB board and use Keilv5 Pro edition for development. My project includes a bootloader and jumps to external SDRAM for my main code. I currently have SNMP, SMTP, and HTTP all working in my project. I recently added SNMP and I can successfully send my board an OID such as " 1.3.6.1.2.1.1.1" and receive the correct information back through SNMP. I used the SNMP_Agent example project as a templet which I also got fully working on the MIMXRT1050-EVKB demo board.

The issue I am having is with sending a SNMP trap in my custom project. In the SNMP_Agent example, I added an SNMP trap and it sends out correctly with no issues using the following function:

netSNMP_Trap (NULL,6,1,NULL);

I attempt the same thing in my project, and I receive a status of "netInvalidParameter". I have figured out that this error is due to the server IP address. The manual states that the first parameter of netSNMP_Trap is the structure containing IP address of the Trap server. If NULL is passed in, the Trap server IP address will be taken from system configuration.

This is my system configuration in both my example and custom project, both exactly the same:


// <h>SNMP Agent
#define SNMP_AGENT_ENABLE 1

// <s.15>Community Name
// <i>Defines where an SNMP message is destined for.
// <i>Default: "public"
#define SNMP_AGENT_COMMUNITY "public"

// <o>Port Number <1-65535>
// <i>Listening port number
// <i>Default: 161
#define SNMP_AGENT_PORT_NUM 161

// <o>Trap Port Number <1-65535>
// <i>Port number for Trap operations
// <i>Default: 162
#define SNMP_AGENT_TRAP_PORT 162

// <s.15>Trap Server
// <i>Trap Server IPv4 Address in text representation
// <i>Default: "192.168.0.100"
#define SNMP_AGENT_TRAP_IP "10.0.2.123"

When I manually input the server IP address, the SNMP trap is successful. Like this:

NET_ADDR SNMP_Server_Addr = { NET_ADDR_IP4, 2000, 10, 0, 2, 123 };

netSNMP_Trap (&SNMP_Server_Addr,6,1,NULL);

Question:

Why am I getting a status error of "netInvalidParameter" from netSNMP_Trap when using NULL as my server address parameter only in my custom project when the same exact code works in the example project?


Any help is appreciated.