don't expect response on disconnect commands

The LWP3 bootloader disconnect and reboot commands cause the device
to disconnect before sending a response, so we must always use
write without response for these, otherwise the program can hang
waiting for a response.
This commit is contained in:
David Lechner
2021-01-19 17:20:56 -06:00
parent 2ff5ce9852
commit 816053ba7c
2 changed files with 8 additions and 3 deletions
+6 -1
View File
@@ -121,6 +121,11 @@ describe('message encoder', () => {
],
],
])('encode %s request', async (_n, request, expected) => {
const messageTypesThatShouldBeCalledWithoutResponse = [
BootloaderRequestActionType.Program,
BootloaderRequestActionType.Reboot,
BootloaderRequestActionType.Disconnect,
];
const saga = new AsyncSaga(bootloader);
saga.put(request);
const message = new Uint8Array(expected);
@@ -128,7 +133,7 @@ describe('message encoder', () => {
expect(action).toEqual(
send(
message,
/* withResponse */ request.type !== BootloaderRequestActionType.Program,
!messageTypesThatShouldBeCalledWithoutResponse.includes(request.type),
),
);
await saga.end();
+2 -2
View File
@@ -81,7 +81,7 @@ function* encodeRequest(): Generator {
);
break;
case BootloaderRequestActionType.Reboot:
yield put(send(createStartAppRequest()));
yield put(send(createStartAppRequest(), /* withResponse */ false));
break;
case BootloaderRequestActionType.Init:
yield put(send(createInitLoaderRequest(action.firmwareSize)));
@@ -96,7 +96,7 @@ function* encodeRequest(): Generator {
yield put(send(createGetFlashStateRequest()));
break;
case BootloaderRequestActionType.Disconnect:
yield put(send(createDisconnectRequest()));
yield put(send(createDisconnectRequest(), /* withResponse */ false));
break;
/* istanbul ignore next: should not be possible to reach */
default: