nativescript-particle
Version:
Control your Particle.io devices from a NativeScript app!
49 lines (48 loc) • 1.83 kB
TypeScript
export declare type TNSParticleDeviceType = "Unknown" | "Core" | "Photon" | "P1" | "Electron" | "RaspberryPi" | "DigistumpOak" | "RedBearDuo" | "Bluz" | "GFConical";
export declare type VariableType = "INT" | "DOUBLE" | "STRING";
export declare function getDeviceType(id: number): TNSParticleDeviceType;
export interface TNSParticleDeviceVariable {
name: string;
type: VariableType;
}
export interface TNSParticleEvent {
prefix: string;
event: string;
data: string;
date: Date;
deviceID: string;
}
export interface TNSParticleDevice {
id: string;
name: string;
status: string;
connected: boolean;
type: TNSParticleDeviceType;
functions: Array<string>;
variables: Array<TNSParticleDeviceVariable>;
eventIds: Map<string, any>;
rename: (name: string) => Promise<void>;
getVariable: (name: string) => Promise<any>;
callFunction: (name: string, ...args: any[]) => Promise<number>;
subscribe: (prefix: string, eventHandler: (event: TNSParticleEvent) => void) => void;
unsubscribe: (prefix: string) => void;
unclaim: () => Promise<void>;
}
export interface TNSParticleLoginOptions {
username: string;
password: string;
}
export interface TNSParticleAPI {
login(options: TNSParticleLoginOptions): Promise<void>;
loginWithToken(token: string): void;
setOAuthConfig(id: string, secret: string): void;
logout(): void;
isAuthenticated(): boolean;
accessToken(): string;
listDevices(): Promise<Array<TNSParticleDevice>>;
startDeviceSetupWizard(): Promise<boolean>;
getDeviceSetupCustomizer(): any;
subscribe(prefix: string, eventHandler: (event: TNSParticleEvent) => void): void;
unsubscribe(prefix: string): void;
publish(name: string, data: string, isPrivate: boolean, ttl?: number): Promise<void>;
}