Skip to content

Class DeviceState

Namespace: Belay.Core
Assembly: Belay.Core.dll

Simple state tracking for MicroPython device operations. Replaces complex session management with lightweight state tracking aligned with single-threaded MicroPython device constraints.

csharp
public sealed class DeviceState

Inheritance

objectDeviceState

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Examples

Basic Usage

using var device = Device.FromConnectionString("subprocess:micropython");
await device.ConnectAsync();

// Check device state
Console.WriteLine($"Platform: {device.State.Capabilities?.Platform}");
Console.WriteLine($"Features: {device.State.Capabilities?.SupportedFeatures}");
Console.WriteLine($"Connection: {device.State.ConnectionState}");

Remarks

This class provides minimal state tracking for MicroPython devices without the complexity of session management. It tracks basic device capabilities, current operations for debugging, and timing information for monitoring.

Unlike the previous session management system, this approach:

  • Eliminates race conditions from concurrent session creation
  • Reduces memory overhead from session tracking
  • Provides direct device operations without session indirection
  • Aligns with single-threaded MicroPython device reality

Properties

Capabilities

Gets or sets the detected device capabilities.

ConnectionState

Gets the current connection state of the device.

CurrentOperation

Gets the name of the current operation being executed.

LastOperationTime

Gets the timestamp of the last completed operation.

Methods

ClearExecutionHistory()

Clears all execution history and operation tracking.

CompleteOperation()

Marks an operation as completed and updates timing information.

SetCurrentOperation(string?)

Sets the current operation and updates internal tracking.

ToString()

Gets a summary of the current device state.

Released under the Apache License 2.0.