What model of Electron are you using (G350, U260, U270, etc.)?
And could you add this to your code?
SerialLogHandler logHandler(LOG_LEVEL_ALL);
Note: Make sure your device has been flashed with v1.0.1 firmware locally from the Particle CLI with
particle update
or via all 3 system binariesparticle flash --usb system-part1-1.0.1-electron.bin
from the github release if you prefer. This is required to ensure the binaries have been built using DEBUG_BUILD=y to get the AT commands in the logs. If your device updated via Safe Mode Healer because you flashed a v1.0.1 app, the resulting system firmware will not contain DEBUG_BUILD=y.
I tested the code in the first post, with that line added, on an Electron U260 (3G Americas), running Device OS 1.0.1, monitoring the USB serial port using:
particle serial monitor --follow
My Electron was able to immediately reconnect with no difficulties. I let it repeat 10 times and it only took less than 10 seconds to reconnect each time.
The TRACE
log SerialLogHandler logHandler(LOG_LEVEL_TRACE);
would be helpful in determining what step of the reconnection process is failing for you and help isolate the problem.
The ALL
log SerialLogHandler logHandler(LOG_LEVEL_ALL);
will provide full AT command details straight away though, so that is preferred.