1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-14 20:10:11 +03:00

implementing openDevice and claimInterface

This commit is contained in:
cTn 2014-06-08 20:26:28 +02:00
parent b5a1015610
commit 92f9b40fc0

View file

@ -58,15 +58,36 @@ var STM32DFU_protocol = function() {
STM32DFU_protocol.prototype.connect = function(hex) {
var self = this;
self.hex = hex;
chrome.usb.getDevices(usbDevices.STM32DFU, function(result) {
if (result.length) {
console.log('USB DFU detected with ID: ' + result[0].device);
self.openDevice(result[0]);
} else {
// TODO: throw some error
}
});
};
STM32DFU_protocol.prototype.openDevice = function(callback) {
STM32DFU_protocol.prototype.openDevice = function(device) {
var self = this;
chrome.usb.openDevice(device, function(handle) {
self.handle = handle;
console.log('Handle ID: ' + handle.handle);
self.claimInterface(0);
});
};
STM32DFU_protocol.prototype.closeDevice = function(callback) {
};
STM32DFU_protocol.prototype.claimInterface = function(callback) {
STM32DFU_protocol.prototype.claimInterface = function(interfaceNumber) {
chrome.usb.claimInterface(this.handle, interfaceNumber, function claimed() {
console.log('Claimed interface: ' + interfaceNumber);
});
};
STM32DFU_protocol.prototype.releaseInterface = function(callback) {