Skip to content

Commit 18af760

Browse files
Fix connect after partial flash and PF progress
1 parent 68bf32d commit 18af760

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/connection-stage-actions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { getHexFileUrl, HexType } from "./device/get-hex-file";
3131
import { HexUrl } from "./model";
3232
import { ConnectOptions } from "./store";
3333
import { downloadHex } from "./utils/fs-util";
34+
import { delay } from "./device/capacitor-ble/bluetooth";
3435

3536
type FlowStage = Pick<ConnectionStage, "flowStep" | "flowType">;
3637

@@ -170,6 +171,10 @@ export class ConnectionStageActions {
170171
// We'll be in Preparing at this point but from now on we want to just
171172
// connect/disconnect for accelerometer data.
172173
this.setStatus(ConnectionStatus.NotConnected);
174+
175+
// TODO: Tune delay.
176+
// If we try to reconnect to soon then we'll time out as it'll still be booting at least in the PF case (DFU seemed OK).
177+
await delay(2000);
173178
await this.connectBluetooth(false);
174179
return;
175180
}

src/device/capacitor-ble/flashing-partial.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,8 @@ const partialFlashInternal = async (
117117
} else {
118118
progress(
119119
FlashProgressStage.Partial,
120-
Math.round(
121-
((offset - fileCodeRegion.start) /
122-
(fileCodeRegion.end - fileCodeRegion.start)) *
123-
100
124-
)
120+
(offset - fileCodeRegion.start) /
121+
(fileCodeRegion.end - fileCodeRegion.start)
125122
);
126123
}
127124
}
@@ -132,7 +129,7 @@ const partialFlashInternal = async (
132129
await delay(100); // allow time for write to complete
133130
await pf.writeEndOfFlashPacket();
134131
await delay(100); // allow time for write to complete
135-
progress(FlashProgressStage.Partial, 100);
132+
progress(FlashProgressStage.Partial, 1);
136133

137134
return PartialFlashResult.Success;
138135
} catch (e) {

0 commit comments

Comments
 (0)