Update IP in NetOS 7.1


Can anyone point me in a direction of an example or show the code to change the IP-adress on ETH0 in NetOS 7.1.

I get the new IP from a serial packet, and I want to set that IP as the new IP on ETH0.

Please help …/—/…


Doesn’t matter!

I figured it out!

Here’s how:

int status;

NaIamParams_t *interface;
devBoardParamsType nvParams; 
// Read current settings.
interface = customizeIamFindInterfaceConfig(BP_ETH_INTERFACE, &nvParams.iamParamsInfo);
if (interface == NULL) {
		interface = customizeIamFindInterfaceConfig(BP_ETH_INTERFACE, &nvParams.iamParamsInfo);
interface->staticParams.IPV4_ADDR(ipAddress) = iplong; 

//Enabling the static configuration will cause DHCP, BOOTP, etc. to be
// ignored on this interface.
interface->staticParams.isEnabled = TRUE;

status = customizeWriteDevBoardParams(&nvParams);

if (status != BP_SUCCESS) {
printf("Error setting new IP
} else {
//printf("IP: %s
customizeReset(); /* reset*/


I am using NetOS 7.3, and I do it this way:

int result;
NaIamParamsInfo_t *config;
NaIamParams_t *eth0Config;

config = malloc( sizeof( NaIamParamsInfo_t ) );
result = customizeIamGetConfig( config );
if( result != BP_SUCCESS )
printf( "Error reading configuration.
" );
eth0Config = customizeIamFindInterfaceConfig( “eth0”, config );

eth0Config->staticParams.ipAddress.addr.ipv4.sin_addr.s_addr = *(u32 *)theValuePtr;

result = customizeIamSetInterfaceConfig( “eth0”, eth0Config );
if( result != BP_SUCCESS )
printf( "Error saving configuration.
" );

But I have a problem, when the application is started it gets the default IP address from appconf.h, instead of taking the new configuration saved in NVRAM.

The APP_USE_NVRAM is defined like this:

jakobvibe, when you reset your board, does it work with the new IP address?


Problem solved.

Sorry for the stupid question. I had selected the option to reset parameters to factory results and checked the “don’t ask again” box when debugging my application.

I was not able to make the environment ask me again when starting to debug, but I changed the debugResetToDefaults parameter to false in the com.digi.netos.prefs project file. Now parameters are read from NVRAM.

Best regards,