Extend the enterSafeMode() method to use a custom DfuSe command for entering safe mode when the device is in DFU mode.
Test app:
const { getDevices } = require('particle-usb');
async function run() {
let dev;
try {
// Open the first found USB device
const devs = await getDevices();
if (!devs.length) {
throw new Error('No devices found');
}
dev = devs[0];
if (!dev.isInDfuMode) {
throw new Error('Device is not in DFU mode');
}
await dev.open();
await dev.enterSafeMode();
} catch (err) {
console.error(err);
process.exit(1);
} finally {
if (dev) {
await dev.close();
}
}
}
run();
Extend the
enterSafeMode()
method to use a custom DfuSe command for entering safe mode when the device is in DFU mode.Test app: