minor code improvements in flash-firmware

This commit is contained in:
David Lechner
2021-01-21 12:37:29 -06:00
parent 6f6bf26854
commit 3b31412186
+4 -8
View File
@@ -298,14 +298,10 @@ function* flashFirmware(action: FlashFirmwareFlashAction): Generator {
throw Error(`Failed to init: ${init}`);
}
let count = 0;
const maxDataSize = MaxProgramFlashSize.get(info[0].hubType);
if (maxDataSize === undefined) {
// istanbul ignore next: indicates programmer error if reached
throw Error('Missing hub type in MaxProgramFlashSize');
}
// 14 is "safe" size for all hubs
const maxDataSize = MaxProgramFlashSize.get(info[0].hubType) || 14;
for (let offset = 0; ; ) {
for (let count = 1, offset = 0; ; count++) {
const payload = firmware.slice(offset, offset + maxDataSize);
const programAction = (yield put(
programRequest(
@@ -329,7 +325,7 @@ function* flashFirmware(action: FlashFirmwareFlashAction): Generator {
// the hub because of sending too much data at once. The actual
// number of packets that can be queued in the Bluetooth chip on
// the hub is not known and could vary by device.
if (++count % 10 === 0) {
if (count % 10 === 0) {
const checksumAction = (yield put(
checksumRequest(nextMessageId()),
)) as BootloaderChecksumRequestAction;