mirror of
https://github.com/esphome/esp-web-tools.git
synced 2025-07-28 14:16:41 +00:00
Migrate to native reset when available (#544)
This commit is contained in:
parent
cd74083edf
commit
ce5650244d
27
src/flash.ts
27
src/flash.ts
@ -6,20 +6,6 @@ import {
|
|||||||
Manifest,
|
Manifest,
|
||||||
FlashStateType,
|
FlashStateType,
|
||||||
} from "./const";
|
} from "./const";
|
||||||
import { sleep } from "./util/sleep";
|
|
||||||
|
|
||||||
const resetTransport = async (transport: Transport) => {
|
|
||||||
await transport.device.setSignals({
|
|
||||||
dataTerminalReady: false,
|
|
||||||
requestToSend: true,
|
|
||||||
});
|
|
||||||
await sleep(250);
|
|
||||||
await transport.device.setSignals({
|
|
||||||
dataTerminalReady: false,
|
|
||||||
requestToSend: false,
|
|
||||||
});
|
|
||||||
await sleep(250);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const flash = async (
|
export const flash = async (
|
||||||
onEvent: (state: FlashState) => void,
|
onEvent: (state: FlashState) => void,
|
||||||
@ -67,7 +53,7 @@ export const flash = async (
|
|||||||
"Failed to initialize. Try resetting your device or holding the BOOT button while clicking INSTALL.",
|
"Failed to initialize. Try resetting your device or holding the BOOT button while clicking INSTALL.",
|
||||||
details: { error: FlashError.FAILED_INITIALIZING, details: err },
|
details: { error: FlashError.FAILED_INITIALIZING, details: err },
|
||||||
});
|
});
|
||||||
await resetTransport(transport);
|
await esploader.hardReset();
|
||||||
await transport.disconnect();
|
await transport.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -88,7 +74,7 @@ export const flash = async (
|
|||||||
message: `Your ${chipFamily} board is not supported.`,
|
message: `Your ${chipFamily} board is not supported.`,
|
||||||
details: { error: FlashError.NOT_SUPPORTED, details: chipFamily },
|
details: { error: FlashError.NOT_SUPPORTED, details: chipFamily },
|
||||||
});
|
});
|
||||||
await resetTransport(transport);
|
await esploader.hardReset();
|
||||||
await transport.disconnect();
|
await transport.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -135,7 +121,7 @@ export const flash = async (
|
|||||||
details: err.message,
|
details: err.message,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await resetTransport(transport);
|
await esploader.hardReset();
|
||||||
await transport.disconnect();
|
await transport.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -213,7 +199,7 @@ export const flash = async (
|
|||||||
message: err.message,
|
message: err.message,
|
||||||
details: { error: FlashError.WRITE_FAILED, details: err },
|
details: { error: FlashError.WRITE_FAILED, details: err },
|
||||||
});
|
});
|
||||||
await resetTransport(transport);
|
await esploader.hardReset();
|
||||||
await transport.disconnect();
|
await transport.disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -228,9 +214,8 @@ export const flash = async (
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
await sleep(100);
|
await esploader.hardReset();
|
||||||
console.log("HARD RESET");
|
|
||||||
await resetTransport(transport);
|
|
||||||
console.log("DISCONNECT");
|
console.log("DISCONNECT");
|
||||||
await transport.disconnect();
|
await transport.disconnect();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user