From 5f7a63fe5a3410f0dc71d1648a1ff31300d582f2 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Mon, 27 Dec 2021 11:11:03 -0600 Subject: [PATCH] ble-lwp3-service/protocol: add enums for hub types This is the full list of hub types. --- src/ble-lwp3-service/protocol.ts | 52 ++++++++++++++++++++++++++++++++ src/lwp3-bootloader/protocol.ts | 4 ++- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 src/ble-lwp3-service/protocol.ts diff --git a/src/ble-lwp3-service/protocol.ts b/src/ble-lwp3-service/protocol.ts new file mode 100644 index 00000000..4ddb149d --- /dev/null +++ b/src/ble-lwp3-service/protocol.ts @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2021 The Pybricks Authors +// +// Constants and helper functions for LEGO Wireless protocol v3. +// +// https://lego.github.io/lego-ble-wireless-protocol-docs/ + +/** + * LEGO Powered Up Hub type IDs + * + * https://github.com/pybricks/technical-info/blob/master/assigned-numbers.md#hub-type-ids + */ +export enum HubType { + /** WeDo 2.0 uses different protocol so shouldn't be seen in LWP3. */ + WeDo2Hub = 0x00, + /** Duplo train hub. */ + DuploTrainHub = 0x20, + /** BOOST Move hub. */ + MoveHub = 0x40, + /** 2-port System hub. */ + CityHub = 0x41, + /** Remote Control. */ + Handset = 0x42, + /** Mario minifig. */ + Mario = 0x43, + /** Luigi minifig. */ + Luigi = 0x44, + /** 4-port Technic hub. */ + TechnicHub = 0x80, + /** 6-port SPIKE/MINDSTORMS hub. */ + TechnicLargeHub = 0x81, + /** 2-port SPIKE hub. */ + TechnicSmallHub = 0x83, +} + +/** + * Variants of the 6-port Technic Large hub. + */ +export enum TechnicLargeHubVariant { + /** Yellow SPIKE Prime variant. */ + SpikePrimeHub = 0, + /** Teal MINDSTORMS Robot Inventor variant. */ + MindstormsInventorHub = 1, +} + +/** + * Variants of the 2-port Technic Small hub. + */ +export enum TechnicSmallHubVariant { + /** Yellow SPIKE Essential variant. */ + SpikeEssentialHub = 0, +} diff --git a/src/lwp3-bootloader/protocol.ts b/src/lwp3-bootloader/protocol.ts index 8bf6e238..107bc47e 100644 --- a/src/lwp3-bootloader/protocol.ts +++ b/src/lwp3-bootloader/protocol.ts @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2020 The Pybricks Authors +// Copyright (c) 2020-2021 The Pybricks Authors // Ref: https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#lego-hub-boot-loader-service @@ -22,6 +22,8 @@ export const MaxMessageSize = 20; /** * LEGO Powered Up Hub IDs + * + * This is the subset of hubs that actually support this bootloader protocol. */ export enum HubType { MoveHub = 0x40,