TeslasuitDocumentation
APIs

Device manager

The TsDeviceManager class is responsible for managing the connection and disconnection of TESLASUIT devices. It provides access to connected devices and their properties, enabling seamless interaction with the TESLASUIT ecosystem.

Class TsDeviceManager#

Handles the connection and disconnection of Teslasuit devices. Provides access to connected devices and their properties.

Class attributes#

devices: list#

A list of connected devices. Each device is an instance of the TsDevice class. The devices attribute maintains a list of all currently connected TESLASUIT devices. Each device in the list is represented as an instance of the TsDevice class, which provides access to device-specific functionality.

Class methods#

wait_for_device_to_connect(self, number_of_devices_to_wait=1)#

Waits for a specified number of devices to connect. This method blocks execution until the specified number of devices are connected. It periodically checks the connection status and prints a message while waiting.

Args:

  • number_of_devices_to_wait (int): Number of devices to wait for. Defaults to 1.
get_or_wait_last_device_attached(self)#

Returns the last connected device or waits for a device to connect if none are available. If no devices are currently connected, this method waits for a device to connect using the wait_for_device_to_connect method. Once a device is connected, it returns the most recently attached device.

Returns:

Notes#

  • The TsDeviceManager class automatically subscribes to device connection and disconnection events. Devices are added to or removed from the devices list dynamically.
  • Ensure that the Teslasuit SDK is properly initialized before using this class to avoid errors.

Selecting a specific device#

get_or_wait_last_device_attached() is the simplest path when only one device is connected. When multiple suits or gloves are connected simultaneously, wait for all of them first and then filter manager.devices by whichever property uniquely identifies the one you want.

Wait for multiple devices#

manager = api.get_device_manager()
manager.wait_for_device_to_connect(number_of_devices_to_wait=2)

# manager.devices now contains all connected devices
for device in manager.devices:
    print(device.get_product_type(), device.get_device_serial())

Select by device type#

Use get_product_type() which returns a TsDeviceType enum value (Suit or Glove).

from teslasuit_sdk.ts_data_structures import TsDeviceType

manager.wait_for_device_to_connect(number_of_devices_to_wait=2)

suit  = next(d for d in manager.devices if d.get_product_type() == TsDeviceType.Suit)
glove = next(d for d in manager.devices if d.get_product_type() == TsDeviceType.Glove)

Select by serial number#

The serial number is printed on the device and returned as a string by get_device_serial().

TARGET_SERIAL = "TS-0042"

manager.wait_for_device_to_connect(number_of_devices_to_wait=2)

device = next(
    d for d in manager.devices if d.get_device_serial() == TARGET_SERIAL
)

Select by UUID#

Each device has a unique device_uuid attribute assigned by the SDK at connection time.

TARGET_UUID = "a1b2c3d4-..."

manager.wait_for_device_to_connect(number_of_devices_to_wait=2)

device = next(d for d in manager.devices if d.device_uuid == TARGET_UUID)

Tip. To discover the serial number or UUID of a device, connect it alone and print device.get_device_serial() or device.device_uuid before adding the second device.


Explore these references and guides to go further with device discovery and selection:

Essential API references#

Practical guides & examples#

Deeper dives & broader concepts#

  • Teslasuit Main Concepts: Fundamental articles covering Teslasuit's core technology and how its subsystems interact.