But, no wake up. it reaches the code (put LED on in part of code USBDevice.wakeupHost())
It is really hard to guess why it is not working with too little information.
The compile errors look a bit like you saved the cpp files as HTML instead of raw cpp files. Have a look at the content of the files in an ASCII editor.
Can you please describe your scenario in detail? Which operating system are you using, what kind of hardware (notebook, desktop, Mac, PC, Tablet), when do you connect and start the Arduino, is USB wakeup enabled in your BIOS and Operating System settings, ...
Can you wakeup your PC with a USB keyboard or mouse on the same USB port in the same scenario?
Do you have any "unknown" USB devices in your system configuration? Do you see the two Arduino HID mice and the Arduino HID keyboard in you system configuration?
USB wakeup is needs many components work together and is a bit complicated. The following preconditions must be met:
- The Arduino Leonardo must be connected to the PC
before the PC goes to sleep mode. When Arduino or the PC loose power, wakeup will fail
- The Arduino (and all USB HUBs between the PC and the Arduino) must be powered when the PC goes to standby mode. You will see this when the Arduino Leonardo power LEDs still lights when in standby mode.
- Other power modes than the "standby" mode (S3) like hibernate (S4 or S5) might also work, but this depends on many factors
When it doesn't work try it without a USB hub between the PC and the Arduino. Notebook USB ports may internally be connected via a USB HUB, so try a different USB port.
I have attached an updated version of the test sketch. You might have to fiddle with the include lines (I can't test it with 1.0.5 right now).
What blink codes do you see?
1. When starting the Leonardo
2. when you activate sleep mode (wait up to 40 seconds after activating it, OSX needs 40 seconds on my Mac and 10 seconds on Windows 7)
3. When you resume from sleep mode (by connecting pin 2 to GND for a second)
4. When the operating system reacts to the resume signal
I've ported the code to Arduino 1.5.8, but Arduino V1.0.5 and V1.0.6 required the outdated (and insecure) Java 6 version on the Mac, therefore I can't use these versions at the moment. When I have it running with 1.0.6, I will attach the new files.
Michael