Skip to content

Commit 4ae4a78

Browse files
committed
ble.lwp3: add port messages and bytecodes
This adds commands in the 0x4X range.
1 parent 09dbe55 commit 4ae4a78

File tree

3 files changed

+1532
-188
lines changed

3 files changed

+1532
-188
lines changed

pybricksdev/ble/lwp3/bytecodes.py

Lines changed: 89 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,10 @@ class MessageKind(IntEnum):
355355
PORT_VALUE_COMBO = 0x46
356356
"""Value update from a mode combo."""
357357

358-
PORT_INFO_FMT = 0x47
358+
PORT_INPUT_FMT = 0x47
359359
"""Reply to a :attr:`PORT_INPUT_FMT_SETUP`."""
360360

361-
PORT_INFO_FMT_COMBO = 0x48
361+
PORT_INPUT_FMT_COMBO = 0x48
362362
"""Reply to a :attr:`PORT_INPUT_FMT_SETUP_COMBO`."""
363363

364364
VIRTUAL_PORT_SETUP = 0x61
@@ -672,8 +672,8 @@ class IODeviceKind(IntEnum):
672672
REMOTE_BUTTONS = 0x37
673673
"""Powered Up Handset Buttons."""
674674

675-
REMOTE_STATUS_LIGHT = 0x38
676-
"""Powered Up Handset Light?"""
675+
HUB_RSSI = 0x38
676+
"""Powered Up hub Bluetooth RSSI"""
677677

678678
HUB_IMU_ACCEL = 0x39
679679
"""Powered Up hub built-in IMU accelerometer."""
@@ -910,3 +910,88 @@ def _missing_(cls, value):
910910

911911
def __repr__(self) -> str:
912912
return f"({repr(self.family)} + {repr(self.subfamily)})"
913+
914+
915+
class InfoKind(IntEnum):
916+
PORT_VALUE = 0x00
917+
MODE_INFO = 0x01
918+
COMBOS = 0x02
919+
920+
921+
class ModeInfoKind(IntEnum):
922+
NAME = 0x00
923+
RAW = 0x01
924+
PCT = 0x02
925+
SI = 0x03
926+
SYMBOL = 0x04
927+
MAPPING = 0x05
928+
INTERNAL_USE = 0x06
929+
MOTOR_BIAS = 0x07
930+
CAPABILITIES = 0x08
931+
UNK9 = 0x09
932+
UNK10 = 0x0A
933+
UNK11 = 0x0B
934+
UNK12 = 0x0C
935+
FORMAT = 0x80
936+
937+
938+
class PortInfoFormatSetupCommand(IntEnum):
939+
SET = 0x01
940+
"""Set mode and data format combos."""
941+
942+
LOCK = 0x02
943+
"""Lock I/O device for setup."""
944+
945+
UNLOCK_ENABLED = 0x03
946+
"""Unlock and start with updates enabled."""
947+
948+
UNLOCK_DISABLED = 0x04
949+
"""Unlock and start with updates disabled."""
950+
951+
RESERVED = 0x05
952+
"""Not used."""
953+
954+
RESET = 0x06
955+
"""Reset I/O device."""
956+
957+
958+
class ModeCapabilities(IntFlag):
959+
960+
OUTPUT = 1 << 0
961+
INTPUT = 1 << 1
962+
LOGICAL_COMBINABLE = 1 << 2
963+
LOGICAL_SYNCHRONIZEABLE = 1 << 3
964+
965+
966+
class IODeviceMapping(IntFlag):
967+
DISCRETE = 1 << 2
968+
RELATIVE = 1 << 3
969+
ABSOLUTE = 1 << 4
970+
SUPPORTS_MAPPING_V2 = 1 << 6
971+
SUPPORTS_NULL = 1 << 7
972+
973+
974+
class IODeviceCapabilities(IntFlag):
975+
"""
976+
Sensor capabilities flags. (48-bit)
977+
"""
978+
979+
pass
980+
981+
982+
class DataFormat(IntEnum):
983+
"""
984+
I/O Device data format.
985+
"""
986+
987+
DATA8 = 0x00
988+
"""8-bit signed integer."""
989+
990+
DATA16 = 0x01
991+
"""16-bit signed integer, little-endian."""
992+
993+
DATA32 = 0x02
994+
"""32-bit signed integer, little-endian."""
995+
996+
DATAF = 0x03
997+
"""32-bit floating point, little-endian."""

0 commit comments

Comments
 (0)