import { Packet } from "./packet"; import { ControlAnnounceFlags } from "./constants"; import { JDBus } from "./bus"; import { JDService } from "./service"; import { JDNode } from "./node"; import { FirmwareInfo, FirmwareUpdater } from "./flashing"; import { LEDController } from "./ledcontroller"; import { JDEventSource } from "./eventsource"; import { ServiceFilter } from "./filters/servicefilter"; /** * Pipe information * @category Runtime */ export interface PipeInfo { pipeType?: string; localPipe?: any; } export interface DeviceStats { dropped: number; restarts: number; announce: number; } /** * Collects packet statistics about the device * @category JDOM */ export declare class DeviceStatsMonitor extends JDEventSource { private _receivedPackets; private _restarts; private _announce; private readonly _data; private _dataIndex; /** * @internal */ constructor(); /** * Number of announce packets received by the device **/ get announce(): number; /** * Average packet dropped per announce period * @category Statistics */ get dropped(): number; /** * Number of restarts within the last 64 announce packets */ get restarts(): number; /** * Gets the current stats */ private get current(); /** * @internal */ processAnnouncement(pkt: Packet): void; /** * @internal */ processPacket(pkt: Packet): void; /** * @internal */ processRestart(): void; toString(): string; } /** * A Jacdac device hosting services. * @category JDOM */ export declare class JDDevice extends JDNode { /** * Indicates if the device is connected to a bus * @category Lifecycle */ connected: boolean; private _source; private _replay; private _lost; private _servicesData; private _statusLight; /** * Timestamp when the device was first seen */ readonly created: number; /** * Timestamp of the last packet received from the device * @category Lifecycle */ lastSeen: number; /** * Timestamp of the last service update packet received from the device * @category Lifecycle */ lastServiceUpdate: number; private _shortId; private _anonymizedId; private _services; private _ports; private _ackAwaiting; private _firmwareUpdater; private _identifying; private _eventCounter; /** * Gets the bus this device belongs to * @category JDOM */ readonly bus: JDBus; /** * Gets the device identifier * @category Control */ readonly deviceId: string; /** * Gets a random device id for the lifetime of this object. */ get anonymizedDeviceId(): string; /** * @internal */ constructor(bus: JDBus, deviceId: string, pkt?: Packet); /** * Quality of service statistics for this device * @category Diagnostics */ readonly stats: DeviceStatsMonitor; /** * Gets a description of the device. * @returns a descriptive string for this device * @category Diagnostics */ describe(): string; /** * Gets a unique identifier for this device in the bus * @category JDOM */ get id(): string; /** * Gets the short id of the device * @category JDOM */ get name(): string; /** * Identifies node as a device * @category JDOM */ get nodeKind(): string; /** * Indicates if the devices is a physical device, not emulated. * @category Transport */ get isPhysical(): boolean; /** * Indicates the source of packets * @category Transport */ get source(): string; /** * Indicates if the device is part of a trace replay * @category Transport */ get replay(): boolean; /** * Gets the device short name * @category JDOM */ get friendlyName(): string; /** * Gets the device short name * @category JDOM */ get qualifiedName(): string; /** * Indicates if service information is available. * This happens after a announce packet has been received. * @category Lifecycle */ get announced(): boolean; /** * Gets the control announce flag from the annouce packet. * @category Control */ get announceFlags(): ControlAnnounceFlags; /** * Gets the restart counter from the announce packet. * @category Control */ get restartCounter(): number; /** * Gets the status light announce flags from the announce packet. * @category Control */ get statusLightFlags(): ControlAnnounceFlags; /** * Indicates if the device is announced as a client * @category Control */ get isClient(): boolean; /** * Gets the number of packets sent since the last announce packet, * as read from the announce packet. * @category Control */ get packetCount(): number; /** * Gets the device short identifier * @category JDOM */ get shortId(): string; /** * Gets the bus instance hosting this device. * @category JDOM */ get parent(): JDNode; /** * Gets the firmware information if any. * @category Firmware */ get firmwareInfo(): FirmwareInfo; private refreshFirmwareInfo; /** * Indicates if no packet from this device has been observed in a while. * @category Lifecycle */ get lost(): boolean; /** * Sets the lost status * @category Lifecycle * @internal */ set lost(v: boolean); /** * Firmware updater, defined if a firmware update is in progress */ get firmwareUpdater(): FirmwareUpdater; /** * Sets the flashing sequence state * @category Firmware */ set firmwareUpdater(value: FirmwareUpdater); /** * Gets the number of events received by the service clients in this device * @category Lifecycle */ get eventCounter(): number; /** * @internal */ set eventCounter(v: number); /** * Indicates if the device contains at least one service matching the service class * @param serviceClass service class to match * @returns true if at least one service present * @category Services */ hasService(serviceClass: number): boolean; /** * Gets or allocates a pipe port * @param id identifier of the port * @returns a pipe port * @category Services */ port(id: number): PipeInfo; /** * Indicates if the service is in bootloader mode * @category Services */ get bootloader(): boolean; /** * Gets the number of services hosted by the device * @category Services */ get serviceLength(): number; /** * Gets the service class at a given index * @param index index of the service * @returns service class * @category Services */ serviceClassAt(index: number): number; /** * Gets the list of service classes * @category Services */ get serviceClasses(): number[]; private initServices; /** * Gets the service client at the given service index * @param serviceIndex index of the service client * @returns service client * @category Services */ service(serviceIndex: number): JDService; /** * Gets a filtered list of service clients. * @param options filters for services * @returns services matching the filter * @category Services */ services(options?: ServiceFilter): JDService[]; /** * Gets the list of child services. * @category JDOM */ get children(): JDNode[]; /** * @internal */ sendCtrlCommand(cmd: number, payload?: Uint8Array): Promise; /** * @internal */ processAnnouncement(pkt: Packet): void; /** * Check if the device is still there * @returns true if the device is there, undefined on timeout */ ping(): Promise; private markRepeatedEvent; /** * @internal */ processPacket(pkt: Packet): void; /** * @internal */ disconnect(): void; /** * Gets a controller for the status light. Returns undefined if the device does not support a status light. * @category Control */ get statusLight(): LEDController; /** * Sends an ``identify`` command to the device * @category Lifecycle */ identify(): Promise; /** * Indicates the device should be identifying. * @category Lifecycle */ get identifying(): boolean; /** * Sends a ``reset`` command to the device * @category Lifecycle */ reset(): Promise; /** * Send command to enter proxy/dongle mode * @returns */ startProxy(): Promise; /** * Tries to retrive the product identifier from the device * @param retry number of attempts * @returns promise that returns product identifier if received * @category Control */ resolveProductIdentifier(retry?: number): Promise; /** * Returns the product identifier synchronously. If needed, tries to refresh the value in the background. * @category Control */ get productIdentifier(): number; /** * Gets the elapsed time since boot in milli-seconds * @category Control */ get uptime(): number; /** * Tries to retrive the firmware version from the device * @param retry number of attempts * @returns promise that returns firmware if received * @category Control */ resolveFirmwareVersion(retry?: number): Promise; /** * Returns the firmware version synchronously. If needed, tries to refresh the value in the background. * @category Control */ get firmwareVersion(): string; /** * Indicates if the device is in proxy mode */ get proxy(): boolean; /** * Indicates if the device is a unique brain */ get brain(): boolean; private initAcks; /** * @internal */ sendPktWithAck(pkt: Packet): Promise; /** * @internal */ floodPing(numPkts?: number, size?: number): Promise; } //# sourceMappingURL=device.d.ts.map