Update: 在线版支持对serial/hid/usb设备进行过滤
This commit is contained in:
@@ -170,6 +170,9 @@ Boards.changeTo = (boardName) => {
|
|||||||
}, {
|
}, {
|
||||||
type: 'upload',
|
type: 'upload',
|
||||||
obj: BOARD.web.upload
|
obj: BOARD.web.upload
|
||||||
|
}, {
|
||||||
|
type: 'devices',
|
||||||
|
obj: BOARD.web.devices
|
||||||
}]) {
|
}]) {
|
||||||
if (!(value.obj instanceof Object)) {
|
if (!(value.obj instanceof Object)) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -1628,6 +1628,7 @@
|
|||||||
"path": "/web/hid.js",
|
"path": "/web/hid.js",
|
||||||
"require": [
|
"require": [
|
||||||
"Mixly.Serial",
|
"Mixly.Serial",
|
||||||
|
"Mixly.Config",
|
||||||
"Mixly.Web"
|
"Mixly.Web"
|
||||||
],
|
],
|
||||||
"provide": [
|
"provide": [
|
||||||
@@ -1659,6 +1660,7 @@
|
|||||||
"require": [
|
"require": [
|
||||||
"Mixly.Serial",
|
"Mixly.Serial",
|
||||||
"Mixly.Debug",
|
"Mixly.Debug",
|
||||||
|
"Mixly.Config",
|
||||||
"Mixly.Web"
|
"Mixly.Web"
|
||||||
],
|
],
|
||||||
"provide": [
|
"provide": [
|
||||||
@@ -1670,6 +1672,7 @@
|
|||||||
"require": [
|
"require": [
|
||||||
"Mixly.Serial",
|
"Mixly.Serial",
|
||||||
"Mixly.Registry",
|
"Mixly.Registry",
|
||||||
|
"Mixly.Config",
|
||||||
"Mixly.Web"
|
"Mixly.Web"
|
||||||
],
|
],
|
||||||
"provide": [
|
"provide": [
|
||||||
@@ -1682,6 +1685,7 @@
|
|||||||
"DAPjs",
|
"DAPjs",
|
||||||
"Mixly.Serial",
|
"Mixly.Serial",
|
||||||
"Mixly.Registry",
|
"Mixly.Registry",
|
||||||
|
"Mixly.Config",
|
||||||
"Mixly.Web"
|
"Mixly.Web"
|
||||||
],
|
],
|
||||||
"provide": [
|
"provide": [
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
goog.loadJs('web', () => {
|
goog.loadJs('web', () => {
|
||||||
|
|
||||||
goog.require('Mixly.Serial');
|
goog.require('Mixly.Serial');
|
||||||
|
goog.require('Mixly.Config');
|
||||||
goog.require('Mixly.Web');
|
goog.require('Mixly.Web');
|
||||||
goog.provide('Mixly.Web.HID');
|
goog.provide('Mixly.Web.HID');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
Serial,
|
Serial,
|
||||||
|
Config,
|
||||||
Web
|
Web
|
||||||
} = Mixly;
|
} = Mixly;
|
||||||
|
|
||||||
|
const { SELECTED_BOARD } = Config;
|
||||||
|
|
||||||
class WebHID extends Serial {
|
class WebHID extends Serial {
|
||||||
static {
|
static {
|
||||||
@@ -31,9 +34,13 @@ class WebHID extends Serial {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.requestPort = async function () {
|
this.requestPort = async function () {
|
||||||
const devices = await navigator.hid.requestDevice({
|
let options = SELECTED_BOARD?.web?.devices?.hid;
|
||||||
filters: []
|
if (options && typeof(options) !== 'object') {
|
||||||
});
|
options = {
|
||||||
|
filters: []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const devices = await navigator.hid.requestDevice(options);
|
||||||
if (!devices.length) {
|
if (!devices.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,15 +2,18 @@ goog.loadJs('web', () => {
|
|||||||
|
|
||||||
goog.require('Mixly.Serial');
|
goog.require('Mixly.Serial');
|
||||||
goog.require('Mixly.Debug');
|
goog.require('Mixly.Debug');
|
||||||
|
goog.require('Mixly.Config');
|
||||||
goog.require('Mixly.Web');
|
goog.require('Mixly.Web');
|
||||||
goog.provide('Mixly.Web.SerialPort');
|
goog.provide('Mixly.Web.SerialPort');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
Serial,
|
Serial,
|
||||||
Debug,
|
Debug,
|
||||||
|
Config,
|
||||||
Web
|
Web
|
||||||
} = Mixly;
|
} = Mixly;
|
||||||
|
|
||||||
|
const { SELECTED_BOARD } = Config;
|
||||||
|
|
||||||
class WebSerialPort extends Serial {
|
class WebSerialPort extends Serial {
|
||||||
static {
|
static {
|
||||||
@@ -33,7 +36,13 @@ class WebSerialPort extends Serial {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.requestPort = async function () {
|
this.requestPort = async function () {
|
||||||
const serialport = await navigator.serial.requestPort();
|
let options = SELECTED_BOARD?.web?.devices?.serial;
|
||||||
|
if (options && typeof(options) !== 'object') {
|
||||||
|
options = {
|
||||||
|
filters: []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const serialport = await navigator.serial.requestPort(options);
|
||||||
this.addPort(serialport);
|
this.addPort(serialport);
|
||||||
this.refreshPorts();
|
this.refreshPorts();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,15 +2,19 @@ goog.loadJs('web', () => {
|
|||||||
|
|
||||||
goog.require('Mixly.Serial');
|
goog.require('Mixly.Serial');
|
||||||
goog.require('Mixly.Registry');
|
goog.require('Mixly.Registry');
|
||||||
|
goog.require('Mixly.Config');
|
||||||
goog.require('Mixly.Web');
|
goog.require('Mixly.Web');
|
||||||
goog.provide('Mixly.Web.USBMini');
|
goog.provide('Mixly.Web.USBMini');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
Serial,
|
Serial,
|
||||||
Registry,
|
Registry,
|
||||||
|
Config,
|
||||||
Web
|
Web
|
||||||
} = Mixly;
|
} = Mixly;
|
||||||
|
|
||||||
|
const { SELECTED_BOARD } = Config;
|
||||||
|
|
||||||
class USBMini extends Serial {
|
class USBMini extends Serial {
|
||||||
static {
|
static {
|
||||||
this.type = 'usb';
|
this.type = 'usb';
|
||||||
@@ -33,9 +37,13 @@ class USBMini extends Serial {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.requestPort = async function () {
|
this.requestPort = async function () {
|
||||||
const device = await navigator.usb.requestDevice({
|
let options = SELECTED_BOARD?.web?.devices?.usb;
|
||||||
filters: []
|
if (options && typeof(options) !== 'object') {
|
||||||
});
|
options = {
|
||||||
|
filters: []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const device = await navigator.usb.requestDevice(options);
|
||||||
this.addPort(device);
|
this.addPort(device);
|
||||||
this.refreshPorts();
|
this.refreshPorts();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,19 @@ goog.loadJs('web', () => {
|
|||||||
goog.require('DAPjs');
|
goog.require('DAPjs');
|
||||||
goog.require('Mixly.Serial');
|
goog.require('Mixly.Serial');
|
||||||
goog.require('Mixly.Registry');
|
goog.require('Mixly.Registry');
|
||||||
|
goog.require('Mixly.Config');
|
||||||
goog.require('Mixly.Web');
|
goog.require('Mixly.Web');
|
||||||
goog.provide('Mixly.Web.USB');
|
goog.provide('Mixly.Web.USB');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
Serial,
|
Serial,
|
||||||
Registry,
|
Registry,
|
||||||
|
Config,
|
||||||
Web
|
Web
|
||||||
} = Mixly;
|
} = Mixly;
|
||||||
|
|
||||||
|
const { SELECTED_BOARD } = Config;
|
||||||
|
|
||||||
class USB extends Serial {
|
class USB extends Serial {
|
||||||
static {
|
static {
|
||||||
this.type = 'usb';
|
this.type = 'usb';
|
||||||
@@ -34,9 +38,13 @@ class USB extends Serial {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.requestPort = async function () {
|
this.requestPort = async function () {
|
||||||
const device = await navigator.usb.requestDevice({
|
let options = SELECTED_BOARD?.web?.devices?.usb;
|
||||||
filters: []
|
if (options && typeof(options) !== 'object') {
|
||||||
});
|
options = {
|
||||||
|
filters: []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const device = await navigator.usb.requestDevice(options);
|
||||||
this.addPort(device);
|
this.addPort(device);
|
||||||
this.refreshPorts();
|
this.refreshPorts();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user