I'm trying implement this new way of configuring the network, but it doesn't seem to persist through a power-cycle. I'm not using the discovery webpage to change the configuration, because that is not the method most of our customers will use. I have a command to instruct the module to use either DHCP or Static IP. A new module defaults to DHCP.
When a command to change to Static is received, the following function is called:
Code: Select all
void UpdateEnetMode( bool dhcp )
config_chooser confChooser = ifBlock->ip4.mode;
confChooser.GetNameValue( confName );
iprintf( "%s current value: %s\r\n", confName.c_str(), NBString( confChooser ).c_str() );
if ( dhcp ) strcpy( newVal, "DHCP" );
else strcpy( newVal, "Static" );
if ( strcmp( newVal, NBString( confChooser ).c_str() ) == 0 ) return;
confChooser = newVal;
I'm not sure if WaitForActiveNetworks needs to be called each time the network configuration is changed, but it doesn't seem to matter if it's used or not.
When the above function completes, the module is in Static mode, and I can communicate with it using the Static address. When it reboots, the module goes back to DHCP mode.
Interestingly, the static IP address is saved and persists through a power-cycle. I can see it in the discovery configuration webpage.
So changed the mode to Static IP through the discovery configuration webpage and it persists through a power-cycle. Then I changed it back to DHCP through the configuration webpage and rebooted. The module is still using the Static address, the discovery webpage reports that the module is using the DHCP address, and I've clicked on the "Refresh" button several times. But clicking on the "ConfigPage" link does nothing. I can no longer get to the configuration page. I've rebooted several times, closed the discovery webpage and reopened it in a new tab. No change. Eventually I get error message "This page isn't working."
The module is a NANO with v3.3.4 tools.