LEGO Wireless Protocol v3 device

Warning

This is an experimental class. It has not been well tested and may be changed in future.

../_images/powereduphubs.png
class LWP3Device(hub_kind, name=None, timeout=10000)

Connects to a remote hub running official LEGO firmware using the the LEGO Wireless Protocol v3

Parameters
  • hub_kind (int) – The hub type identifier of the hub to connect to.

  • name (str) – The name of the hub to connect to or None to connect to any hub.

  • timeout (int) – The time, in milliseconds, to wait for a connection before raising an exception.

name(name=None)

Gets or sets the Bluetooth name of the remote.

If no name is given, this method returns the current name.

Parameters

name (str) – New Bluetooth name of the remote.

write(buf)

Sends a message to the remote hub.

Parameters

buf (bytes) – The raw binary message to send.

read()

Retrieves the most recent message received from the remote hub.

If a message has not been received since the last read, the method will block until a message is received.

Returns

The raw binary message.

Return type

bytes