Technical Deep Dive: NE2-S1W Network Link Management and Reconnection (Auto-Mode)
For industrial IoT applications, a dropped connection can lead to data loss or system downtime. The NE2-S1W serial server module features a sophisticated link management system designed to handle seamless transitions between Ethernet and WiFi.
This guide details the internal logic of the Auto-Selection Mode, explaining how the device prioritizes links and maintains stable data transmission.
1. Power-on Initialization
Upon startup, the device enters a standby state until a valid IP address is obtained via either Ethernet (ETH) or WiFi.
-
Once an IP is assigned, the system immediately initiates the corresponding user link and triggers a Ping test.
-
The system waits for the Ping result to verify end-to-end network reachability before proceeding.
2. Ping Flag Rules
The "Ping Success" flag is governed by specific priority rules to ensure the most stable link is used:
-
ETH Ping: Once the Ethernet Ping is successful, the flag is set immediately.
-
WiFi Ping: * If the ETH interface currently has a valid IP, the system waits for the ETH Ping result before setting the flag.
-
If the ETH interface has no IP, the flag is set immediately upon a successful WiFi Ping.
-
-
Note: All subsequent Ping operations first verify if the network card has a valid IP; only active interfaces are tested.
3. Socket Creation & Connection
Once the "Ping Success" flag is detected, the user task initiates the communication sequence:
-
Create Socket: A new communication socket is initialized.
-
Bind Link: The socket is bound to the specific network interface (ETH or WiFi) that passed the Ping test.
-
Connection Request: The device initiates a connection to the server and sets a "Connecting" status flag.
4. Successful Connection
When the handshake is complete and the link is established, the "Connection Successful" flag is set, and data transmission begins.
5. Disconnection Recovery Logic
When a link drops, the NE2-S1W distinguishes between disconnection types to apply the correct recovery strategy:
5.1 Active vs. Passive Disconnection
-
Active Disconnection (e.g., manual closure during a link switch): The system skips the Ping test and immediately attempts to reconnect using the existing valid Ping results.
-
Passive Disconnection (e.g., network failure, server timeout): The system follows a recovery flow based on current link availability.
5.2 Single-Link Scenario
If only one network interface is available, the system immediately re-triggers a Ping test and waits for a successful result before attempting to reconnect.
5.3 Dual-Link Scenario
If both interfaces are active, the system checks the "other" link:
-
If the other link is already connected: The current disconnected link tries to reconnect to the server automatically.
-
If the other link is currently "Connecting": The system waits for that result (Success/Failure) before deciding the next step.
-
If the other link is disconnected/failed: A Ping test is immediately triggered on the current link to prepare for reconnection.
6. Link Switching (Ethernet Priority)
A key feature of the NE2-S1W is its Ethernet-first policy. If the device is currently connected via WiFi and the Ethernet connection is restored:
-
ETH obtains an IP and successfully passes its Ping test.
-
An "Active Disconnection" flag is triggered within the ETH Ping callback.
-
The user socket task detects this flag, actively closes the local WiFi-bound socket, and initiates a reconnection—this time binding to the superior ETH interface.
7. Ping Configuration & Best Practices
To ensure accurate network detection, the device supports a robust probing mechanism:
-
Configurable Targets: Users can configure up to 3 Ping server addresses (IP or Domain). Note: Using IP addresses is highly recommended to avoid delays or failures caused by DNS resolution.
-
Polling Mechanism: The device pings servers in sequence. If all targets fail, it waits for the user-defined Ping Interval (60–65535s) before starting a new round.
-
Server Selection: For the most reliable results, set the Ping targets to the actual business server IP or its gateway. This ensures the Ping result accurately reflects the reachability of your specific application.
-
Configuration Warning: Incorrect Ping targets (unreachable addresses or isolated networks) will cause Ping tests to fail perpetually, which will prevent the link from ever being established.