///
///
import TypedEmitter from 'typed-emitter';
import { ISerialConnector } from './iserialconnector';
export declare enum EiSerialWifiSecurity {
EI_SECURITY_NONE = 0,
EI_SECURITY_WEP = 1,
EI_SECURITY_WPA = 2,
EI_SECURITY_WPA2 = 3,
EI_SECURITY_WPA_WPA2 = 4,
EI_SECURITY_PAP = 5,
EI_SECURITY_CHAP = 6,
EI_SECURITY_EAP_TLS = 7,
EI_SECURITY_PEAP = 8,
EI_SECURITY_UNKNOWN = 255
}
export declare enum EiSerialSensor {
EI_CLASSIFIER_SENSOR_UNKNOWN = -1,
EI_CLASSIFIER_SENSOR_MICROPHONE = 1,
EI_CLASSIFIER_SENSOR_ACCELEROMETER = 2,
EI_CLASSIFIER_SENSOR_CAMERA = 3,
EI_CLASSIFIER_SENSOR_9DOF = 4,
EI_CLASSIFIER_SENSOR_ENVIRONMENTAL = 5
}
export interface EiSerialDeviceConfig {
info: {
id: string;
type: string;
atCommandVersion: {
major: number;
minor: number;
patch: number;
};
transferBaudRate: number | undefined;
};
sensors: {
name: string;
maxSampleLengthS: number;
frequencies: number[];
}[];
inference: {
sensor: EiSerialSensor;
modelType: 'classification' | 'constrained_object_detection';
};
snapshot: {
hasSnapshot: boolean;
supportsStreaming: boolean;
colorDepth: 'RGB' | 'Grayscale';
resolutions: {
width: number;
height: number;
}[];
};
wifi: {
present: boolean;
ssid: string;
password: string;
security: EiSerialWifiSecurity;
connected: boolean;
};
sampling: {
label: string;
interval: number;
length: number;
hmacKey: string;
};
upload: {
apiKey: string;
host: string;
path: string;
};
ingestion_cycle: {
sensor: string;
ingestion_cycle_length: number;
ingestion_interval: number;
};
management: {
url: string;
connected: boolean;
lastError: string;
};
}
export interface EiSerialWifiNetwork {
ssid: string;
security: EiSerialWifiSecurity;
securityString: string;
rssi: number;
line: string;
}
export type EiStartSamplingResponse = TypedEmitter<{
samplingStarted: () => void;
processing: () => void;
uploading: () => void;
readingFromDevice: (progressPercentage: number) => void;
done: (ev: EiSerialDone) => void;
error: (ex: string) => void;
}>;
export type EiSnapshotResponse = TypedEmitter<{
started: () => void;
readingFromDevice: (progressPercentage: number) => void;
done: (data: Buffer) => void;
error: (ex: string) => void;
}>;
export interface EiSerialDoneFs {
filename: string;
onDeviceFileName: string;
file?: Buffer;
}
export interface EiSerialDoneBuffer {
filename: string;
onDeviceFileName: string;
file: Buffer;
label: string;
}
export type EiSerialDone = EiSerialDoneFs | EiSerialDoneBuffer;
export default class EiSerialProtocol {
private _serial;
private _config;
/**
*
* @param serial An instance of the serial connector
*/
constructor(serial: ISerialConnector);
onConnected(): Promise;
clearConfig(): Promise;
getConfig(): Promise;
setDeviceID(deviceId: string): Promise;
setUploadSettings(apiKey: string, url: string): Promise;
setUploadHost(host: string): Promise;
setSampleSettings(label: string, interval: number, length: number, hmacKey: string): Promise;
setIngestionCycleSettings(sensor_name: string, cycle_length: number, cycle_interval: number): Promise;
setWifi(ssid: string, password: string, security: EiSerialWifiSecurity): Promise;
scanWifi(): Promise;
setRemoteManagement(url: string): Promise;
startSampling(sensor: string | undefined, length: number): EiStartSamplingResponse;
unlink(file: string): Promise;
takeSnapshot(width: number, height: number): Promise;
stopInference(): Promise;
startInference(mode: 'normal' | 'debug' | 'continuous'): Promise;
startSnapshotStream(resolution: 'low' | 'high'): Promise<{
ee: TypedEmitter<{
snapshot: (b: Buffer, w: number, h: number) => void;
error: (err: string) => void;
}>;
stop: () => Promise;
}>;
private sleep;
private execCommand;
/**
* Wait until a certain sequence is seen on the serial port
* @param seq Buffer with the exact sequence
* @param timeout Timeout in milliseconds
*/
private waitForSerialSequence;
/**
* Wait until a certain sequence is seen on the serial port
* @param seq Buffer with the exact sequence
* @param timeout Timeout in milliseconds
*/
private getSerialSequenceCallback;
/**
* Take the serial response and grab the actual response from the device
* @param data
*/
private parseSerialResponse;
/**
* Wait for a command to finish and optionally switch to max baud rate for it
* @param ee
* @param timeout
* @param logProgress
*/
private execCommandAutoSwitchBaudRate;
private shouldUseMaxBaudrate;
private basename;
}