webusb / arduino

WebUSB demos running on Arduino (and compatible) hardware.
580 stars 154 forks source link

A little doc? #48

Closed ANSB closed 6 years ago

ANSB commented 6 years ago

I use the Lib and it works fine, despite the lack of coment in the examples which made them not very easy to understand. :) My question is about the WebUSB WebUSBSerial(1, "url"); call. I notice the url is not mandatory and if you don't add it, Chrome don't display its small Box. But what about the first parameter? Can you explain its meaning and possible values? Thanks!

reillyeon commented 6 years ago

I just added documentation for this parameter last week:

/*
 * Together |landingPageScheme| and |landingPageUrl| tell the browser
 * what page the user should visit in order to interact with their
 * device. |landingPageScheme| can have any of the following values:
 *
 *  0x00 -> "http://"
 *  0x01 -> "https://"
 *
 * This prefix is combined with |landingPageUrl| to produce the full
 * URL.
 */
WebUSB(uint8_t landingPageScheme, const char* landingPageUrl);

(From https://github.com/webusb/arduino/blob/gh-pages/library/WebUSB/WebUSB.h#L51)

ANSB commented 6 years ago

OK thanks. Not sure the value of 0 can be usefull as Chrome only accept https for webusb... (dont know on Windows or Linux, but with Chrome 65 on OSX, http is not allowed)

reillyeon commented 6 years ago

http:// is allowed because according to the specification http://localhost is considered a secure context.

ANSB commented 6 years ago

👍