The PC it is connected to runs Windows 7 and am using a 8 port USB hub.
Next tested on a Macbook Pro. It then became obvious what was happening:
Calling Keyboard.begin() closes the usb Serial (ie screen /dev/cu.usbmodem621 returns)
BUT, I can re-rerun screen /dev/cu.usbmodem621, and it opens okay.
Back to Windows 7, if you open PuTTy upon startup, nothing received, but after closing PuTTy you can't connect again. But if you start the Photon, wait a little bit and then open PuTTy, it will see output.
Obviously this a problem. Will raise a Github issue.
Hmm... it's very important to follow the driver notes to the letter for Windows. But I see you say this is happening on Mac as well. We'll look into this!
We will be making an installer for this process, so don't think it will always be so difficult. For now though, I do appreciate your help testing this, thanks
This is expected. By the time setup() is called, the device has already been enumerated to the host. By default, only Serial is enabled in order to keep compatibility with “old” Windows drivers.
When Keyboard.begin() is called, the device needs to change its USB descriptors that are presented during enumeration, open additional endpoints etc etc. There is no way to do all that without performing a reattach (i.e. disconnect/reconnect).
If that behavior is undesirable, you can always call Keyboard.begin() in STARTUP(), which will make the device attach for the first time after boot with both Serial and Keyboard:
Just to clarify: STARTUP(Keyboard.begin()); doesn’t cause the Serial and Keyboard to operate at the same time. They can still operate at the same time even if you call Keyboard.begin() in setup(), the only difference being that in this case the device will first appear as just having Serial, then detach, reattach, and only then it will have both Serial and USB HID.