Potential WebUSB Study Syllabus
I followed through the steps of an Adafruit WebUSB example and established connection between Chrome browser on my Android phone to a microcontroller plugged into the USB port on the phone. I think WebUSB would enable many of my project ideas. But before I can turn any of my vague ideas into reality, I have a lot of homework to do.
The Adafruit example was thin on background information. I think it was written for people who already know how to work with TinyUSB library and just wanted to see Adafruit's adaptation into an Arduino library. This impression is backed up by the fact its GitHub repository README (https://github.com/adafruit/Adafruit_TinyUSB_Arduino) is written using vocabulary I don't understand. Following the link to TinyUSB's site gives me similar language, so I have to start climbing my learning curve from somewhere else.
Searching from the browser side, I found a Chrome developer documentation page on WebUSB. I was able to comprehend more of this page, but not all of it. Here I learned one constraint on WebUSB: web apps are only allowed to connect to USB devices the operating system doesn't already have a driver for. This is a mitigation against malicious apps bypassing operating system protection for USB devices like security keys. It also avoids ambiguity/duplication with existing functionality. For example, there's no real need for a web app to interface with a USB keyboard via WebUSB when the operating system can already deliver key press events. Though there's an interesting wrinkle here around USB serial, a common way to connect to microcontroller projects. By this rule, a web app can't connect to a USB serial device on my desktop via WebUSB because my operating system already knows how to work with a serial device. (So it's over to Web Serial land.) But apparently Android lacks a built-in handler for serial, so maybe it's available via WebUSB? At this point I don't yet know if that's an opportunity or just a source of confusion.
Fortunately for beginners like myself, author of this Chrome developer documentation page included a link to USB in a NutShell for those unfamiliar with fundamental USB concepts. Hey, that's me! I will try to start with USB in a NutShell and work my way back to TinyUSB and its various incarnations like Adafruit's Arduino library. But that's just the "USB" part, I have a lot I'll have to learn for the "Web" part as well.