Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DFU support for PWA #3949

Merged
merged 6 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/js/port_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@ import { get as getConfig } from "./ConfigStorage";
import serial from "./serial";
import MdnsDiscovery from "./mdns_discovery";
import { isWeb } from "./utils/isWeb";
import { usbDevices } from "./usb_devices";

const TIMEOUT_CHECK = 500 ; // With 250 it seems that it produces a memory leak and slowdown in some versions, reason unknown

export const usbDevices = { filters: [
{'vendorId': 1155, 'productId': 57105}, // STM Device in DFU Mode || Digital Radio in USB mode
{'vendorId': 10473, 'productId': 393}, // GD32 DFU Bootloader
{'vendorId': 0x2E3C, 'productId': 0xDF11}, // AT32F435 DFU Bootloader
{'vendorId': 12619, 'productId': 262}, // APM32 DFU Bootloader
] };

const PortHandler = new function () {
this.currentPorts = [];
this.initialPorts = false;
Expand Down
13 changes: 9 additions & 4 deletions src/js/protocols/stm32.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@ import { bit_check } from "../bit";
import { gui_log } from "../gui_log";
import MSPCodes from "../msp/MSPCodes";
import PortUsage from "../port_usage";
import PortHandler, { usbDevices } from "../port_handler";
import PortHandler from "../port_handler";
import { API_VERSION_1_42 } from "../data_storage";
import serial from "../serial";
import STM32DFU from "./stm32usbdfu";
import semver from "semver";
import $ from 'jquery';

import { usbDevices } from "../usb_devices";
import { serialShim } from "../serial_shim";
import { usbShim } from "../usb_shim";

let serial = serialShim();
let dfu = usbShim();

const STM32_protocol = function () {
this.baud = null;
this.options = {};
Expand Down Expand Up @@ -112,7 +117,7 @@ STM32_protocol.prototype.connect = function (port, baud, hex, options, callback)
// refresh device list
PortHandler.check_usb_devices(function(dfu_available) {
if (dfu_available) {
STM32DFU.connect(usbDevices, hex, options);
dfu.connect(usbDevices, hex, options);
} else {
serial.connect(self.port, {bitrate: self.baud, parityBit: 'even', stopBits: 'one'}, function (openInfo) {
if (openInfo) {
Expand Down
Loading