Represents a session with a Pixel die. This class is used to abstract the underlying platform used to connect to Pixels.

Constructors

  • Instantiates a session with a Pixel. No attempt is made to connect to the die at this point.

    Parameters

    • systemId: string

      The peripheral system id (as assigned by the OS).

    • Optionalname: string

    Returns PixelSession

Properties

_connStatusCb?: ((ev: PixelSessionConnectionEvent) => void)
_systemId: string

Accessors

  • get lastConnectionStatus():
        | "connected"
        | "connecting"
        | "disconnected"
        | "failedToConnect"
        | "ready"
        | "disconnecting"
  • Gets the last known connection status.

    Returns
        | "connected"
        | "connecting"
        | "disconnected"
        | "failedToConnect"
        | "ready"
        | "disconnecting"

  • get pixelName(): undefined | string
  • Gets the Pixel name.

    Returns undefined | string

    It may be undefined until connected.

  • get systemId(): string
  • Gets the peripheral system id (as assigned by the OS).

    Returns string

Methods

  • Parameters

    • status:
          | "connected"
          | "connecting"
          | "disconnected"
          | "failedToConnect"
          | "ready"
          | "disconnecting"
    • Optionalreason:
          | "canceled"
          | "success"
          | "unknown"
          | "host"
          | "timeout"
          | "notSupported"
          | "linkLoss"
          | "bluetoothOff"
          | "peripheral"

    Returns void

  • Parameters

    • name: string

    Returns void

  • Connects to the Pixel.

    Parameters

    • timeoutMs: number

    Returns Promise<void>

  • Disconnects from the Pixel.

    Returns Promise<void>

  • Release resources used by the session object.

    Returns void

  • Sets the function to be called when the Pixel connection status changes.

    Parameters

    Returns void

  • Subscribes to the "notify" characteristic and returns unsubscribe function.

    Parameters

    • listener: ((dataView: DataView) => void)

      The function to be called when the Pixel connection status changes.

        • (dataView): void
        • Parameters

          • dataView: DataView

          Returns void

    Returns Promise<(() => void)>

  • Sends data to Pixel using the "write" characteristic

    Parameters

    • data: ArrayBuffer

      The raw data to send to the Pixel.

    • OptionalwithoutResponse: boolean

      Whether or not to request the device to acknowledge having received the data.

    • OptionaltimeoutMs: number

      The timeout in milliseconds before throwing an error when waiting for the device to acknowledgement.

    Returns Promise<void>