## Issue Summary
**Platform:** AmebaPro2 (AMB82-MINI)
**Arduino Core:** realtek:AmebaPro2 4.0.9
**WiFi Library:** Built-in WiFi.h
**Severity:** High (prevents connection to networks with underscores in SSID)
**Status:** Workaround available, root cause not fixed—
## Problem Description
The WiFi driver on AmebaPro2 **corrupts SSID names** containing underscore characters (`_`) by replacing them with dots (`.`) during automatic reconnection attempts. This prevents successful connection to WiFi networks with underscores in their SSID.
### Observed Behavior
When attempting to connect to a network with SSID `MOVISTAR_36F7`:
1. **Initial connection attempt:** SSID is passed correctly as `MOVISTAR_36F7`
2. **Connection fails or times out**
3. **Auto-reconnect triggers:** Driver internally changes SSID to `MOVI.STAR_36F7` (underscore replaced with dot)
4. **Connection fails permanently:** Network cannot be found because SSID is corrupted
### Serial Monitor Output
```
[Driver]: set ssid [MOVISTAR_36F7] (0)
Scan: 1, Auth: 0, Assoc: 0, 4way: 0, connect: 0, reason: 65533
waiting for connection … [6]… [6].
auto reconnect …
[Driver]: set ssid [MOVI.STAR_36F7] .. ← CORRUPTION HERE
[6]… [6]..(1) Scan: 1, Auth: 0, Assoc: 0, 4way: 0, connect: 0, reason: 65533
```
**Note:** The corruption happens in the driver layer, not in application code.
-–
## Reproduction Steps
### Minimal Code to Reproduce
```cpp
#include <WiFi.h>
char ssid = “MOVISTAR_36F7”; // SSID with underscore
char password = “your_password”;
void setup() {
Serial.begin(115200);
delay(1000);
Serial.print("Connecting to: ");
Serial.println(ssid);
// Verify SSID before passing to WiFi.begin()
Serial.print("SSID length: ");
Serial.println(strlen(ssid));
Serial.print("SSID bytes: ");
for (size_t i = 0; i < strlen(ssid); i++) {
Serial.print(" [");
Serial.print(i);
Serial.print(“]='”);
Serial.print(ssid[i]);
Serial.print(“'(”);
Serial.print((int)ssid[i]);
Serial.print(“)”);
}
Serial.println();
WiFi.begin(ssid, password);
int attempts = 0;
while (WiFi.status() != WL_CONNECTED && attempts < 30) {
delay(500);
Serial.print(“.”);
attempts++;
// Monitor SSID corruption
if (attempts % 10 == 0) {
Serial.println();
Serial.print("Status: ");
Serial.println(WiFi.status());
}
}
if (WiFi.status() == WL_CONNECTED) {
Serial.println(“\nConnected!”);
Serial.print("IP: ");
Serial.println(WiFi.localIP());
} else {
Serial.println(“\nConnection failed!”);
}
}
void loop() {
delay(1000);
}
```
### Expected vs Actual Behavior
**Expected:**
- SSID `MOVISTAR_36F7` should be passed to driver unchanged
- Connection should succeed if credentials are correct
**Actual:**
- SSID is corrupted to `MOVI.STAR_36F7` during auto-reconnect
- Connection fails because network with corrupted SSID doesn’t exist
- No way to recover without power cycle
-–
## Technical Analysis
### When Does Corruption Occur?
1. **Initial connection attempt:** SSID is correct
2. **Connection timeout or failure:** Driver enters auto-reconnect mode
3. **Auto-reconnect logic:** Driver internally modifies SSID, replacing `_` with `.`
4. **Subsequent attempts:** Use corrupted SSID, connection impossible
### Root Cause Hypothesis
The corruption appears to happen in the **WiFi driver’s auto-reconnect mechanism**, likely in one of these scenarios:
1. **String processing bug:** Driver may be using a function that treats `_` as a special character
2. **Character encoding issue:** Driver may be converting SSID through a filter that replaces underscores
3. **Memory corruption:** SSID buffer may be overwritten during reconnect logic
4. **Legacy code path:** Auto-reconnect may use an old code path with different SSID handling
### Evidence
1. **SSID is correct in application code:** Verified by printing each character before `WiFi.begin()`
2. **Corruption happens in driver:** Serial output shows `[Driver]: set ssid [MOVI.STAR_36F7]` - this is driver-level output
3. **Only affects auto-reconnect:** Initial attempt uses correct SSID
4. **Consistent behavior:** Happens every time with SSIDs containing underscores
-–
## Affected Networks
Any WiFi network with underscore (`_`) in SSID name:
- `MOVISTAR_36F7` → `MOVI.STAR_36F7` ![]()
- `My_Network` → `My.Network` ![]()
- `Test_123` → `Test.123` ![]()
- `DIGIFIBRA-PLUS-55QK` → Works (no underscore) ![]()
-–
## Workarounds
### Workaround 1: Disable Auto-Reconnect (Recommended)
```cpp
void initWiFi() {
// Explicitly disconnect first
WiFi.disconnect();
delay(2000); // Give time for full disconnection
// Disable auto-reconnect if possible
// Note: WiFi.setAutoReconnect(false) may not be available on all versions
// Connect with explicit SSID
WiFi.begin(ssid, password);
// Monitor connection with timeout
int attempts = 0;
while (WiFi.status() != WL_CONNECTED && attempts < 30) {
delay(500);
attempts++;
// If stuck, force disconnect and retry
if (attempts > 20 && WiFi.status() == WL_DISCONNECTED) {
WiFi.disconnect();
delay(2000);
WiFi.begin(ssid, password); // Explicit reconnect with correct SSID
}
}
}
```
### Workaround 2: Use Network Without Underscore
If possible, rename the WiFi network to avoid underscores:
- `MOVISTAR_36F7` → `MOVISTAR-36F7` (use hyphen instead)
- Or use a network that doesn’t have underscores
### Workaround 3: Manual Reconnect Logic
```cpp
void initWiFi() {
WiFi.disconnect();
delay(2000);
int maxAttempts = 3;
for (int attempt = 0; attempt < maxAttempts; attempt++) {
Serial.print("Attempt ");
Serial.print(attempt + 1);
Serial.print(“/”);
Serial.println(maxAttempts);
// Verify SSID before each attempt
Serial.print("SSID: ");
Serial.println(ssid);
WiFi.begin(ssid, password);
int waitAttempts = 0;
while (WiFi.status() != WL_CONNECTED && waitAttempts < 20) {
delay(500);
waitAttempts++;
}
if (WiFi.status() == WL_CONNECTED) {
Serial.println(“Connected!”);
return;
}
// Force disconnect before retry
WiFi.disconnect();
delay(2000);
}
Serial.println(“Failed to connect after all attempts”);
}
```
-–
## Code Verification
To verify SSID is not corrupted in application code:
```cpp
void verifySSID(char* ssid) {
Serial.println(“=== SSID Verification ===”);
Serial.print(“SSID string: '”);
Serial.print(ssid);
Serial.println(“'”);
Serial.print("Length: ");
Serial.println(strlen(ssid));
Serial.println(“Character breakdown:”);
for (size_t i = 0; i < strlen(ssid); i++) {
Serial.print(" [");
Serial.print(i);
Serial.print(“] = '”);
Serial.print(ssid[i]);
Serial.print("’ (ASCII: ");
Serial.print((int)ssid[i]);
Serial.println(“)”);
}
Serial.println(“========================”);
}
void setup() {
Serial.begin(115200);
delay(1000);
char ssid = “MOVISTAR_36F7”;
// Verify before WiFi.begin()
verifySSID(ssid);
WiFi.begin(ssid, password);
// Monitor during connection
// Check Serial Monitor for driver output showing corruption
}
```
-–
## Driver Version Information
- **Platform:** AmebaPro2 (RTL8735B)
- **Arduino Core:** realtek:AmebaPro2 4.0.9
- **WiFi Driver:** Built into core (version info from Serial Monitor):
```
[Driver]: [HALMAC] 11692M
HALMAC_MAJOR_VER = 1
HALMAC_PROTOTYPE_VER = 4
HALMAC_MINOR_VER = 20
HALMAC_PATCH_VER =
[Driver]: Ver = libwlan:2025.05.27.18.12_b9.6_1acc271a021c89298377c7ed1ac05e5263027e49
```
-–
## Impact
### Severity: High
- **Blocks connection** to legitimate WiFi networks with underscores
- **No user workaround** except avoiding underscores in SSID
- **Affects production deployments** where network names cannot be changed
- **Silent failure** - connection just doesn’t work, no clear error
### Affected Use Cases
- Enterprise networks with naming conventions using underscores
- Guest networks: `Guest_Network`, `WiFi_Guest`
- IoT device networks: `Device_001`, `Sensor_Network`
- Any network where SSID contains `_` character
-–
## Requested Fix
### Expected Behavior
1. SSID should be passed to driver **unchanged**
2. Auto-reconnect should use **original SSID**, not modified version
3. No character substitution should occur in driver layer
### Suggested Fix
1. **Review auto-reconnect code path** in WiFi driver
2. **Identify where SSID modification occurs** (likely string processing function)
3. **Fix character substitution logic** to preserve original SSID
4. **Add validation** to ensure SSID matches original before reconnect attempt
### Testing
Test cases to verify fix:
- `MOVISTAR_36F7` → Should remain `MOVISTAR_36F7`
- `Test_Network_123` → Should remain `Test_Network_123`
- `My_SSID` → Should remain `My_SSID`
- Networks without underscores should continue working
-–
## Additional Observations
### Connection Status Codes
During failed connection attempts, observed status codes:
- `6` = `WL_DISCONNECTED`
- `3` = `WL_CONNECTED` (rarely reached)
- Connection reason: `65533` (driver-specific error code)
### Timing
- Initial connection attempt: ~2-3 seconds
- Auto-reconnect triggers: After ~5-10 seconds of failure
- SSID corruption: Occurs immediately when auto-reconnect activates
- No recovery: Once corrupted, connection never succeeds
### Network Scanning
Network scanning (`WiFi.scanNetworks()`) correctly shows original SSID with underscore. The corruption only affects the connection attempt, not scanning.
-–
## Conclusion
This is a **driver-level bug** that corrupts SSID names containing underscores during auto-reconnect. The issue prevents connection to legitimate networks and requires either:
1. **Driver fix** (recommended) - Fix the auto-reconnect SSID handling
2. **Workaround** - Disable auto-reconnect and implement manual reconnect logic
3. **Network rename** - Avoid underscores in SSID names (not always possible)
**We request this issue be addressed in a future driver/firmware update.**
-–
## Contact Information
**Platform:** AmebaPro2 (AMB82-MINI)
**Arduino Core Version:** realtek:AmebaPro2 4.0.9
**Issue Date:** November 2025
**Reproducible:** Yes, 100% of the time with SSIDs containing underscores
-–
**Thank you for your attention to this issue.**