Skip to content

Commit 9d233c9

Browse files
committed
fix: keep/restore legacy actions
style: minor formatting
1 parent 9e3eb9b commit 9d233c9

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

src/ble-pybricks-service/actions.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2021-2023 The Pybricks Authors
2+
// Copyright (c) 2021-2024 The Pybricks Authors
33
//
44
// Actions for Bluetooth Low Energy Pybricks service
55

@@ -59,7 +59,19 @@ export const sendStopUserProgramCommand = createAction((id: number) => ({
5959
* Action that requests a start user program to be sent.
6060
* @param id Unique identifier for this transaction.
6161
*
62-
* @since Pybricks Profile v1.2.0. Program identifier added in Pybricks Profile v1.4.0.
62+
* @since Pybricks Profile v1.2.0.
63+
*/
64+
export const sendLegacyStartUserProgramCommand = createAction((id: number) => ({
65+
type: 'blePybricksServiceCommand.action.sendLegacyStartUserProgramCommand',
66+
id,
67+
}));
68+
69+
/**
70+
* Action that requests a start user program to be sent.
71+
* @param id Unique identifier for this transaction.
72+
* @param slot Program identifier to start.
73+
*
74+
* @since Pybricks Profile v1.4.0.
6375
*/
6476
export const sendStartUserProgramCommand = createAction(
6577
(id: number, slot?: number) => ({

src/ble-pybricks-service/protocol.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2020-2023 The Pybricks Authors
2+
// Copyright (c) 2020-2024 The Pybricks Authors
33
//
44
// Definitions related to the Pybricks Bluetooth low energy GATT service.
55

@@ -85,15 +85,24 @@ export function createStopUserProgramCommand(): Uint8Array {
8585
/**
8686
* Creates a {@link CommandType.StartUserProgram} message.
8787
*
88-
* The optional payload parameter was added in Pybricks Profile v1.4.0.
88+
* @since Pybricks Profile v1.2.0.
89+
*/
90+
export function createLegacyStartUserProgramCommand(): Uint8Array {
91+
const msg = new Uint8Array(1);
92+
msg[0] = CommandType.StartUserProgram;
93+
return msg;
94+
}
95+
96+
/**
97+
* Creates a {@link CommandType.StartUserProgram} message.
8998
*
9099
* Parameters:
91-
* - payload: Optional program identifier (one byte). Slots 0--127 are
100+
* - slot: Optional program identifier (one byte). Slots 0--127 are
92101
* reserved for downloaded user programs. Slots 128--255 are
93102
* for builtin user programs. If no program identifier is
94103
* given, the currently active program slot will be started.
95104
*
96-
* @since Pybricks Profile v1.2.0. Program identifier added in Pybricks Profile v1.4.0.
105+
* @since Pybricks Profile v1.4.0.
97106
*/
98107
export function createStartUserProgramCommand(slot: number | undefined): Uint8Array {
99108
const msg = new Uint8Array(slot === undefined ? 1 : 2);

src/ble-pybricks-service/sagas.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2021-2023 The Pybricks Authors
2+
// Copyright (c) 2021-2024 The Pybricks Authors
33
//
44
// Handles Pybricks protocol.
55

@@ -61,8 +61,7 @@ function* encodeRequest(): Generator {
6161
a.type.startsWith('blePybricksServiceCommand.action.send'),
6262
);
6363

64-
65-
for (; ;) {
64+
for (;;) {
6665
const action = yield* take(chan);
6766

6867
/* istanbul ignore else: should not be possible to reach */

0 commit comments

Comments
 (0)