Commit Graph
21 Commits
Author SHA1 Message Date
David Lechner 3c4cc20c53 ble-pybricks-service: add support for slots
The firmware has added some additional info for hubs that support slots
for user programs. Add these additional parameters accordingly.
2025-07-26 16:14:40 -05:00
David Lechner 1a7663a383 ble-pybricks-service: rename slot to progId
Rename the requested program ID from slot to progId and the running
program ID to runningProgId. These can also have the value of built-in
programs, not just slot numbers, so it doesn't make sense to call them
slots.
2025-07-26 16:14:40 -05:00
David Lechner 0472978e50 ble-pybricks-service/sagas: simplify test
I meant to change this before merging the previous commit, but missed it.

The mismatch test was hard to understand and didn't increase coverage,
so let's leave it out.
2024-10-27 18:12:24 -05:00
Attila FaragoandDavid Lechner 14f4716dbc Implemented pybricks protocol v1.4.0 (#2317)
* Update for changed StartUserProgram command semantics
* Added new capability flags and fixed-purpose slot definitions
* Update for new start REPL command
* Updated StartUserProgram command and Status event for slots
* Added new AppData command and event

---------

Co-authored-by: David Lechner <david@pybricks.com>
2024-10-27 17:59:04 -05:00
David Lechner 061d22a7aa prettier v3 changes 2023-08-08 08:15:24 -07:00
David Lechner 6d844b78e3 ble-pybricks-service/protocol: add UserProgramMultiMpy6Native6p1
This adds a new flag from Pybricks Profile v1.3.0 for documentation
purposes. We currently don't support native modules in Pybricks Code
so we aren't using this for now.
2023-05-01 12:54:57 -05:00
David Lechner 337209744c add support for Pybricks Profile v1.3.0 2023-04-19 13:03:48 -05:00
David Lechner 63a1026dae ble-pybricks-service: document @since 2023-04-19 13:03:48 -05:00
David Lechner d48734b513 ble-pybricks-service/protocol: add CommandType.ResetInUpdateMode 2022-11-18 19:28:00 -06:00
David Lechner e67ae1c52b use "error" when type is Error
This renames "err" to "error" when the type is Error for consistency
(fixes redux complaints about non-serializable err).
2022-10-17 13:44:21 -05:00
David Lechner 960a3163ed add support for Pybricks Profile v1.2.0
This adds support to the BLE Pybricks Profile v1.2.0. This includes a
new method to download and run programs and a new file format for the
user program.

Code for the old download and run is kept for backwards compatibility.
However, the PnP ID characteristic is no longer optional, so the
minimum Pybricks Profile is now v1.1.0.
2022-10-14 16:21:18 -05:00
David Lechner bbe7eb4df3 ble: avoid aliases for UUID constants 2022-07-15 18:05:48 -05:00
David Lechner a9f4eaa32d actions: simplify usage of Matchable
This removes use of the pseudo-internal toString() function and also
removes extraneous uses of ReturnType<>. Also, a new when() method
is added to simplify additional uses.
2022-02-26 12:43:10 -06:00
David Lechner 9641898a75 actions: refactor actions
The pattern we were using for actions required actions to be defined in
three places, an enum member containing the type string, an type
definition and a function. This combines all three of these into one by
using a helper function based on the ideas from [1].

[1]: https://phryneas.de/redux-typescript-no-discriminating-union
2022-02-25 17:58:30 -06:00
David Lechner 6a9e867fe9 ble-pybricks-service: rename statusReportEvent
New name is didReceiveStatusReport which is more consistent with existing
naming patterns.
2021-12-27 12:38:51 -06:00
David Lechner e7d44ea9a9 src/utils: add ensureError() function
Typescript v4.4 no longer assumes that the error in catch is an Error
object [1]. This adds a helper function to ensure that caught errors
at least match the Error interface. If not, it creates a new Error
object with the value as the message.

[1]: https://devblogs.microsoft.com/typescript/announcing-typescript-4-4-beta/#using-unknown-in-catch-variables
2021-08-30 13:06:01 -05:00
David Lechner ec6753c314 yarn lint
rules seem to have changed a bit after upgrading packages
2021-05-11 12:45:43 -05:00
David Lechner 64c75640ba ble-pybricks-service: add some tests 2021-03-12 08:54:20 -06:00
David Lechner 56829a502c ble-pybricks-service/sagas: fix filtering of command send completions
Since didSend and didFailToSend are part of the same enum as the command
send actions types, we have to filter them out when subscribing to the
send actions.
2021-03-10 11:19:06 -06:00
David Lechner 430147487e implement Pybricks service stop command 2021-03-10 10:30:15 -06:00
David Lechner 61c34fc4b1 implement BLE Pybricks service status notifications
This is the beginning of the BLE Pybricks service implementation, so
changes are made to get a handle to the Pybricks control characteristic
and enable notifications.

Currently, only one event (the status report event) and no commands are
implemented on this characteristic.

The new status report event replaces monitoring the UART for >>>>
strings to get the current hub state.

Also includes some minor cleanup in the ble-uart/actions for consistency.
2021-03-10 10:30:15 -06:00