NetBurner 3.5.6
PDF Version
DHCP Client - Change IP Address

Demonstrate how to view IP address and change between DHCP and static IPv4 IP settings.

DHCP Client - Change IP Address Application

Overview

This application demonstrates how to dynamically switch between DHCP and static IPv4 IP address configurations on a NetBurner embedded device. It provides an interactive menu system through the serial port that allows users to view current network settings and change between addressing modes without requiring a system reboot.

Features

  • Interactive Serial Menu: Control the application through a simple command-line interface
  • Real-time IP Configuration: Switch between DHCP and static IP modes during runtime
  • DHCP State Monitoring: Display current DHCP client state and lease information
  • Network Status Display: View comprehensive IPv4 settings including IP address, subnet mask, gateway, and DNS servers
  • Optional WiFi Support: Configurable WiFi functionality (disabled by default)
  • Web Server Integration: Built-in HTTP server for web-based management

Supported Address Modes

The application supports the following IPv4 addressing modes:

  • DHCP: Automatic IP address assignment from DHCP server
  • DHCP w/ Fallback: DHCP with fallback to static configuration if DHCP fails
  • Static: Manual IP address configuration
  • Disabled: Network interface disabled

Menu Options

The application provides a simple menu system with the following options:

  1. Display Runtime Settings: Shows current IPv4 configuration, DHCP state, and network interface information
  2. Change to Static Address Mode: Switches to static IP configuration using settings from the configuration record
  3. Change to DHCP Address Mode: Enables DHCP client and obtains IP address automatically

Configuration Methods

Method 1: Using Configuration Record (Default)

The application reads static IP settings from the device's configuration record stored in flash memory. This is the recommended approach as it allows settings to persist across reboots.

Method 2: Application-Defined Settings (Optional)

Alternatively, you can define static IP settings directly in the application code by:

  1. Uncommenting the #define statements for static IP values
  2. Uncommenting the AssignStaticIpv4Values() function call
  3. Modifying the IP addresses to match your network environment
#define STATIC_IP "10.1.1.222"
#define STATIC_MASK "255.255.255.0"
#define STATIC_GATE "10.1.1.1"
#define STATIC_DNS1 "10.1.1.1"
#define STATIC_DNS2 "8.8.8.8"

Switching Between Modes

Changing from DHCP to Static

  1. Static settings are read from the configuration record
  2. Address mode is set to "Static"
  3. Configuration is saved to flash memory
  4. Runtime settings are updated immediately (no reboot required)

Changing from Static to DHCP

  1. Static settings can remain intact (they won't affect DHCP operation)
  2. Address mode is set to "DHCP" or "DHCP w/ Fallback"
  3. Configuration is saved to flash memory
  4. DHCP client is restarted to obtain new lease

DHCP State Information

The application monitors and displays the following DHCP client states:

  • DHCP not started: System initialization incomplete
  • DHCP Discover: Searching for DHCP servers
  • DHCP Offer: Received offer from DHCP server
  • DHCP Acknowledge: Accepted DHCP offer
  • DHCP Complete: Successfully obtained valid lease
  • DHCP Renew/Rebind: Lease renewal process
  • DHCP Failed: Could not obtain DHCP lease

Optional Features

WiFi Support

WiFi functionality can be enabled by uncommenting the #define USE_WIFI (1) directive. This requires:

  • WiFi driver initialization
  • QSPI interface configuration
  • Appropriate WiFi hardware support

System Diagnostics

The application includes system diagnostics for debugging purposes. For production deployments, consider removing the EnableSystemDiagnostics() call.

Network Interface Information

The application displays comprehensive network information including:

  • Device name and application name
  • Current addressing mode (DHCP/Static)
  • IPv4 addresses (current and configured)
  • Subnet mask
  • Default gateway
  • Primary and secondary DNS servers
  • Link status and connectivity information

Usage Instructions

  1. Build and Deploy: Compile the application and deploy to your NetBurner device
  2. Connect Serial Terminal: Connect to the device's serial port (typically 115200 baud)
  3. Wait for Network: The application waits up to 5 seconds for network initialization
  4. Use Menu System: Enter menu options (1, 2, or 3) to interact with the application
  5. Monitor Changes: View real-time network configuration changes

Technical Details

  • NNDK Compatibility: Built for NetBurner Network Development Kit
  • Memory Management: Uses configuration server for persistent settings storage
  • Network Stack: Integrates with NetBurner's TCP/IP stack
  • Threading: Runs in NetBurner's multi-tasking environment
  • Error Handling: Includes proper error checking and state management

Development Notes

  • The application uses NetBurner-specific APIs and data structures
  • Format warnings for HI and I parameters are intentionally suppressed
  • The code follows NetBurner's naming conventions and coding standards
  • IPv6 support is conditionally compiled based on IPV6 preprocessor definition

Prerequisites

  • NetBurner development board with Ethernet interface
  • NetBurner Network Development Kit (NNDK)
  • Serial terminal application for user interaction
  • Network infrastructure with DHCP server (for DHCP mode testing)

This application serves as both a practical network management tool and a comprehensive example of NetBurner's networking capabilities for embedded developers.