Serial port not available after upload

I have two versions of code that should work about the same. One is the example program WiFiUdpNtpClient in the WifiNINA set. The other is my attempt to encapsulate it in a couple of classes and use state machines instead of delays. The behavior that I observe is that when I load the example sketch, the code downloads on one port (eg. COM 5 - Windows 10) and then opens a different com port (eg COM3) for the serial communications. The problem comes when I load my modified version. It downloads, but never opens a serial port back to the laptop. I’m wondering if anyone can spot the problem. I’ve attached my sketch. The other one is in the example section of the IDE if you install the WifiNINA library.


TestWifiMod.ino (9.83 KB)

Your problem is here:

    Serial.print(" , ");

You should not do anything with hardware in a constructor because it may run before the hardware has been initialized.