import { Logger } from "tslog"; import { Protobuf, Types } from "./index.js"; import { EventSystem } from "./utils/eventSystem.js"; import { Queue } from "./utils/queue.js"; import { Xmodem } from "./utils/xmodem.js"; /** Base class for connection methods to extend */ export declare abstract class MeshDevice { /** Abstract property that states the connection type */ protected abstract connType: Types.ConnectionTypeName; protected abstract portId: string; /** Logs to the console and the logging event emitter */ protected log: Logger; /** Describes the current state of the device */ protected deviceStatus: Types.DeviceStatusEnum; /** Describes the current state of the device */ protected isConfigured: boolean; /** Are there any settings that have yet to be applied? */ protected pendingSettingsChanges: boolean; /** Device's node number */ private myNodeInfo; /** Randomly generated number to ensure confiuration lockstep */ configId: number; /** * Packert queue, to space out transmissions and routing handle errors and * acks */ queue: Queue; events: EventSystem; xModem: Xmodem; constructor(configId?: number); /** Abstract method that writes data to the radio */ protected abstract writeToRadio(data: Uint8Array): Promise; /** Abstract method that connects to the radio */ protected abstract connect(parameters: Types.ConnectionParameters): Promise; /** Abstract method that disconnects from the radio */ protected abstract disconnect(): void; /** Abstract method that pings the radio */ protected abstract ping(): Promise; /** * Sends a text over the radio */ sendText(text: string, destination?: Types.Destination, wantAck?: boolean, channel?: Types.ChannelNumber): Promise; /** * Sends a text over the radio */ sendWaypoint(waypointMessage: Protobuf.Waypoint, destination: Types.Destination, channel?: Types.ChannelNumber): Promise; /** * Sends packet over the radio */ sendPacket(byteData: Uint8Array, portNum: Protobuf.PortNum, destination: Types.Destination, channel?: Types.ChannelNumber, wantAck?: boolean, wantResponse?: boolean, echoResponse?: boolean, replyId?: number, emoji?: number): Promise; /** * Sends raw packet over the radio */ sendRaw(toRadio: Uint8Array, id?: number): Promise; /** * Writes config to device */ setConfig(config: Protobuf.Config): Promise; /** * Writes module config to device */ setModuleConfig(moduleConfig: Protobuf.ModuleConfig): Promise; /** * Sets devices owner data */ setOwner(owner: Protobuf.User): Promise; /** * Sets devices ChannelSettings */ setChannel(channel: Protobuf.Channel): Promise; setPosition(positionMessage: Protobuf.Position): Promise; /** * Gets specified channel information from the radio */ getChannel(index: number): Promise; /** * Gets devices config * request */ getConfig(configType: Protobuf.AdminMessage_ConfigType): Promise; /** * Gets Module config */ getModuleConfig(moduleConfigType: Protobuf.AdminMessage_ModuleConfigType): Promise; /** Gets devices Owner */ getOwner(): Promise; /** * Gets devices metadata */ getMetadata(nodeNum: number): Promise; /** * Clears specific channel with the designated index */ clearChannel(index: number): Promise; private beginEditSettings; commitEditSettings(): Promise; /** * Resets the internal NodeDB of the radio, usefull for removing old nodes * that no longer exist. */ resetPeers(): Promise; /** Shuts down the current node after the specified amount of time has elapsed. */ shutdown(time: number): Promise; /** Reboots the current node after the specified amount of time has elapsed. */ reboot(time: number): Promise; /** * Reboots the current node into OTA mode after the specified amount of time * has elapsed. */ rebootOta(time: number): Promise; /** Factory resets the current node */ factoryReset(): Promise; /** Triggers the device configure process */ configure(): Promise; /** Sends a trace route packet to the designated node */ traceRoute(destination: number): Promise; /** Requests position from the designated node */ requestPosition(destination: number): Promise; /** * Updates the device status eliminating duplicate status events */ updateDeviceStatus(status: Types.DeviceStatusEnum): void; /** * Generates random packet identifier * * @returns {number} Random packet ID */ private generateRandId; /** * Gets called whenever a fromRadio message is received from device, returns * fromRadio data */ protected handleFromRadio(fromRadio: Uint8Array): void; /** Completes all SubEvents */ complete(): void; /** * Gets called when a MeshPacket is received from device */ private handleMeshPacket; private handleDecodedPacket; }