Skip to content

DeviceController

Keeps the DeviceManager of every device and service on this phone.

This includes the phone itself. A singleton, used by the SmartPhoneClientManager as its DeviceDataCollectorFactory. Device managers come from the SamplingPackages registered in the SamplingPackageRegistry, one per device type, and are kept in devices.

Use it to find a device manager, e.g. to connect a Bluetooth device: SmartPhoneClientManager().deviceController.getDeviceManager(type).

Inheritance

Constructors

DeviceController

DeviceController()

Returns the singleton DeviceController.

Constants

HEARTBEAT_PERIOD

int const HEARTBEAT_PERIOD

The period of sending Heartbeat measurements, in minutes.

Properties

connectedDevices

The device managers whose device is connected now.

devices

The registered device managers, by device type.

localDataCollector

DeviceDataCollector get localDataCollector
override
set localDataCollector (DeviceDataCollector? value)
inherited

The data collector for the primary device.

smartphoneDeviceManager

SmartphoneDeviceManager get smartphoneDeviceManager

The device manager of this phone (the primary device).

Throws a StateError if none is registered.

Methods

createConnectedDataCollector

DeviceManager<DeviceConfiguration<DeviceRegistration>, DeviceRegistration>? createConnectedDataCollector(
  1. String deviceType,
  2. DeviceRegistration deviceRegistration
)
override

Create a ConnectedDeviceDataCollector for a connected deviceType using connection options specified in deviceRegistration.

Returns null in case the ConnectedDeviceDataCollector cannot be created.

devicesToString

String devicesToString()

The short names of all device types in devices, for logging.

disconnectAllConnectedDevices

Future<void> disconnectAllConnectedDevices()

Starts disconnecting all connectedDevices. Does not wait for them.

getDeviceManager

Returns the device manager for deviceType.

If none is registered yet, it is taken from the sampling packages and registered. Returns null if no sampling package provides deviceType.

hasDevice

bool hasDevice(
  1. String deviceType
)

Whether a device manager for deviceType is registered in devices.

registerAllAvailableDevices

void registerAllAvailableDevices()

Registers the device managers of all packages in SamplingPackageRegistry.

registerDevice

void registerDevice(
  1. String deviceType,
  2. DeviceManager<DeviceConfiguration<DeviceRegistration>, DeviceRegistration> manager
)

Registers manager for deviceType.

Does nothing if a manager is already registered for deviceType.

supportsDevice

bool supportsDevice(
  1. String deviceType
)

Whether a registered SamplingPackage provides the device deviceType.

toString

String toString()
override

A string representation of this object.

Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string representation.

Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.

unregisterDevice

void unregisterDevice(
  1. String deviceType
)

Unregister the manager for deviceType.