Documentation
    Preparing search index...

    Type Alias MockSerialService

    MockSerialService: MockService<MockSerialState> & {
        disconnect(sessionId: string, reason?: string): boolean;
        receive(sessionId: string, bytes: readonly number[]): boolean;
    }

    Serial mock with device-side controls.

    Type Declaration

    • disconnect: function
      • Close a session from the device side and push a closed event.

        Parameters

        • sessionId: string

          Open session.

        • Optionalreason: string

          Close reason. Default device disconnected.

        Returns boolean

        false when the session is unknown or already closed.

    • receive: function
      • Push inbound bytes from the device to the session's window.

        Parameters

        • sessionId: string

          Open session.

        • bytes: readonly number[]

          Byte values 0..255.

        Returns boolean

        false when the session is unknown/closed, the bytes are invalid, or no delivery path to the window exists yet.

    const service = createMockSerialService();
    service.receive('serial-1', [79, 75, 10]);
    service.disconnect('serial-1');