From 75e9cb184a8485800eff6dc058fd35ab60de1b63 Mon Sep 17 00:00:00 2001 From: Gerrit Niezen Date: Thu, 22 Dec 2022 15:05:30 +0000 Subject: [PATCH 1/2] always use official cable if 3rd party cable is also connected --- app/actions/async.js | 2 ++ app/main.dev.js | 18 +++++++++++++++++- lib/core/driverManifests.js | 4 ++-- lib/drivers/tandem | 2 +- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/actions/async.js b/app/actions/async.js index 9d47e2a770..b0c8b5056c 100644 --- a/app/actions/async.js +++ b/app/actions/async.js @@ -20,6 +20,7 @@ import semver from 'semver'; import os from 'os'; import { push } from 'connected-react-router'; import { checkCacheValid } from 'redux-cache'; +import { ipcRenderer } from 'electron'; import * as actionTypes from '../constants/actionTypes'; import * as actionSources from '../constants/actionSources'; @@ -369,6 +370,7 @@ export function doUpload(deviceKey, opts, utc) { })); try { + ipcRenderer.send('setSerialPortFilter', filters); opts.port = await navigator.serial.requestPort({ filters: filters }); } catch (err) { // not returning error, as we'll attempt user-space driver instead diff --git a/app/main.dev.js b/app/main.dev.js index f86ef5f986..e3d81cf995 100755 --- a/app/main.dev.js +++ b/app/main.dev.js @@ -47,6 +47,7 @@ console.log('Last crash report:', crashReporter.getLastCrashReport()); let menu; let template; let mainWindow = null; +let serialPortFilter = null; // Web Bluetooth should only be an experimental feature on Linux app.commandLine.appendSwitch('enable-experimental-web-platform-features', true); @@ -186,7 +187,18 @@ operating system, as soon as possible.`, mainWindow.webContents.session.on('select-serial-port', (event, portList, webContents, callback) => { event.preventDefault(); console.log('Port list:', portList); - const [selectedPort] = portList; + + let selectedPort; + for (let i = 0; i < serialPortFilter.length; i++) { + selectedPort = portList.find((element) => + serialPortFilter[i].usbVendorId === parseInt(element.vendorId, 10) && + serialPortFilter[i].usbProductId === parseInt(element.productId, 10) + ); + if (selectedPort) { + break; // prioritize according to the order in the driver manifest + } + } + if (!selectedPort) { callback(''); } else { @@ -522,6 +534,10 @@ ipcMain.on('autoUpdater', (event, arg) => { autoUpdater[arg](); }); +ipcMain.on('setSerialPortFilter', (event, arg) => { + serialPortFilter = arg; +}); + if(!app.isDefaultProtocolClient('tidepoolupload')){ app.setAsDefaultProtocolClient('tidepoolupload'); } diff --git a/lib/core/driverManifests.js b/lib/core/driverManifests.js index a85052dc2e..1f9b1f57a3 100644 --- a/lib/core/driverManifests.js +++ b/lib/core/driverManifests.js @@ -127,8 +127,8 @@ const driverManifests = { OneTouchUltraMini: { mode: 'serial', usb: [ - { vendorId: 1659, productId: 8963, driver: 'pl2303' }, { vendorId: 1027, productId: 24577, driver: 'ftdi' }, // FTDI cable + { vendorId: 1659, productId: 8963, driver: 'pl2303' }, { vendorId: 6790, productId: 29987 }, // CH340 cable ], }, @@ -138,8 +138,8 @@ const driverManifests = { sendTimeout: 5000, receiveTimeout: 5000, usb: [ - { vendorId: 1659, productId: 8963, driver: 'pl2303' }, { vendorId: 1027, productId: 24577, driver: 'ftdi' }, // FTDI cable + { vendorId: 1659, productId: 8963, driver: 'pl2303' }, { vendorId: 6790, productId: 29987 }, // CH340 cable ], }, diff --git a/lib/drivers/tandem b/lib/drivers/tandem index aba2bf600d..37f55c45d0 160000 --- a/lib/drivers/tandem +++ b/lib/drivers/tandem @@ -1 +1 @@ -Subproject commit aba2bf600dce5ddeb39642b41d53fc8be463de0b +Subproject commit 37f55c45d0720f9ec587bbc77e1cabf0a948748a From 52562aecbeaeea9567515b0feb732ab833833c08 Mon Sep 17 00:00:00 2001 From: Gerrit Niezen Date: Thu, 22 Dec 2022 15:06:11 +0000 Subject: [PATCH 2/2] v2.47.4-manufacturer-cable.1 --- app/package.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/package.json b/app/package.json index 51cc40bb30..a51190c644 100644 --- a/app/package.json +++ b/app/package.json @@ -1,7 +1,7 @@ { "name": "tidepool-uploader", "productName": "tidepool-uploader", - "version": "2.47.4", + "version": "2.47.4-manufacturer-cable.1", "description": "Tidepool Project Universal Uploader", "main": "./main.prod.js", "author": { diff --git a/package.json b/package.json index b01881c139..9810283ff4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tidepool-uploader", - "version": "2.47.4", + "version": "2.47.4-manufacturer-cable.1", "description": "Tidepool Project Universal Uploader", "private": true, "main": "main.prod.js",