How is the USB detach with ArduinoLowPower library

Dear All,

I jsut discover a greate library : ArduinoLowPower library.

If a USB cable is connected to my board to my Laptop I would like to have detached before the sleeping mode and reattached after sleeping mode when the bard wake up.

In the library I discover this

void ArduinoLowPowerClass::sleep() {
    bool restoreUSBDevice = false;
    /*
    if (SerialUSB) {
        USBDevice.standby();
    } else {
        USBDevice.detach();
        restoreUSBDevice = true;
    }
    */
    if (Serial) {
        USBDevice.standby();
        Serial.println(F("DEBUG: USB standby"));
    } else {
        Serial.println(F("DEBUG: USB detach"));
        USBDevice.detach();
        restoreUSBDevice = true;
    }


    SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
    __DSB();
    __WFI();
    if (restoreUSBDevice) {
        Serial.println(F("DEBUG: USB attach"));
        USBDevice.attach();
    }
}

I commented a part and replace it with Serial instead of SerialUSB. I am using Feather MO and it do not reconized SerialUSB.

Whatever, I do not understand one things.

Id Serial (or SerialSUB) return true, it's because the USB cable is connected to my board. So it change the USB to standby mode USBDevice.standby();

But I do not see at any time when the USBDevice come back at this normal state after wakeup.

I also do not undertand , when Serial (or SerialUSB) return false, it's meens that not USB cable is connected, it detach the devise and lastely, I also do not understand why when the sleep mode is called, it can attach the devise if the variable 'restoreUSBDevice' is true.

My goal is to make sure, I still can print debug message on my Terminal when my board wakeup. In other word, would like to make sure that my USB cable is reattached or change the mode from standby to normla state.

Any suggestion? Many thank for your advise

when Serial (or SerialUSB) return false, it's meens that not USB cable is connected

It does NOT mean that. The Arduino, or Feather, has NO way of knowing if a USB cable is connected.

Thank PaulS for yur reply. My worries is when the board sleep with ArduinoLowPower library and the boear wake up, the terminal do not print Serial.print() message. As the Serial is in standby

USBDevice.standby();

Then, is there a way to "refresh" the terminal as soon as the board wakeup and having the the Serial.print printed in the terminal for debuging prupose?