export type AuthenticationMethod = 0 | 1; export interface GizBaseCapability { name: string; isActive: boolean; isLogin: boolean; netStatus: NetStatus; connect: () => Promise>; disConnect: () => Promise>; getDeviceInfo: () => Promise>; sendDp: (data: Object) => Promise>; getDp: (attrs?: string[]) => Promise>; checkUpdate: (firmwareType: GizOTAFirmwareType) => Promise>; startUpgrade: (firmwareType: GizOTAFirmwareType, callback: GizOtaProgressCallback) => Promise>; provideWiFiCredentials: (ssid: string, password: string, timeout: number, callback: GizProvideWiFiCredentialsCallback) => Promise>; stopProvideWiFiCredentials: () => Promise>; queryTimer: () => Promise>; deleteTimer: (timerId: number) => Promise>; editTimer: (data: GizDeviceLocalTimerParams) => Promise>; createTimer: (data: GizDeviceLocalTimerParams) => Promise>; } export type GizOTAEvent = 'GizOTAEventCheckingDeviceVersion' | 'GizOTAEventDownloading' | 'GizOTAEventTransferring' | 'GizOTAEventFinish'; export interface GizOTAProgressData { percentage: number; event: GizOTAEvent; } export type GizOtaProgressEventCallback = (data: { device: IDevice; data: GizOTAProgressData; }) => void; export type GizOtaProgressCallback = (event: GizOTAProgressData) => void; export type GizProvideWiFiCredentialsCallback = (event: GizWiFiActivatorEvent) => void; export interface GizCheckUpdateResultInfo { downloadUrl: string; softVersion: string; currentSoftVersion: string; } export interface GizBaseProfile { protocolVersion: number; supportOTA: boolean; requiresAuthentication: boolean; authenticationMethod: AuthenticationMethod; rootDid?: string; configured: boolean; } export type BlueToothType = 'Mesh' | 'Beacon' | 'Voice' | 'GATT'; export type BlueToothVersion = 'BLE4' | 'BLE42' | 'BLE50'; export type NetStatus = 0 | 1 | 2; export type GizWiFiActivatorEventType = 'GIZ_CONNECT_SUCCESS' | 'GIZ_CONFIG_SEND_SUCCESS' | 'GIZ_CONFIG_RECV_SUCCESS' | 'GIZ_ROUTER_CONNECT_RESULT' | 'GIZ_CONFIG_SUCCESS'; export interface GizWiFiActivatorEvent { data: GizWiFiActivatorEventType; } export interface GizLanProfile extends GizBaseProfile { ip: string; port: number; cTime: number; } export interface GizBleProfile extends GizBaseProfile { deviceId: string; cTime: number; RSSI: number; blueToothType: BlueToothType; blueToothVersion: BlueToothVersion; } export interface GizMQTTProfile extends GizBaseProfile { host: string; port: number; } export interface GizBleCapability extends GizBaseCapability { profile: GizBleProfile; } export interface GizLanCapability extends GizBaseCapability { profile: GizLanProfile; } export interface GizMQTTCapability extends GizBaseCapability { profile: GizMQTTProfile; } export interface IDevice { id: string; mac: string; productKey: string; did?: string; isBind: boolean; name: string; bleCapability: GizBleCapability; lanCapability: GizLanCapability; mqttCapability: GizMQTTCapability; bind: (alias?: string, remark?: string) => Promise>; updateDeviceInfo: (alias?: string, remark?: string) => Promise>; unBind: () => Promise>; register: () => Promise>; } export interface IUpdateAuthorizeDataParams { uid: string; token: string; } export interface GizResult { success: boolean; message: string; data?: T; error?: E; } export type GizCallback = (error: GizResult, data: GizResult) => void; export interface ServerInfoStruct { openAPIInfo: string; } export interface ProductInfoStruct { productKey: string; productSecret: string; } export interface GizConfigStruct { appID: string; appSecret: string; productInfos: ProductInfoStruct[]; serverInfo?: ServerInfoStruct; } export type GizDeviceNetStatus = 0 | 1 | 2; export type GizCapability = 'BLE' | 'LAN' | 'MQTT'; export type GizOTAFirmwareType = 'Module' | 'MCU'; export interface DeviceDataRes { device: IDevice; data: GizDeviceData; type: GizCapability; } export interface DeviceStateRes { device: IDevice; state: GizDeviceNetStatus; isLogin: boolean; type: GizCapability; } export interface DeviceBindRes { did: string; isBind: boolean; } export type DeviceDataCallback = (data: DeviceDataRes) => void; export type DeviceStateCallback = (data: DeviceStateRes) => void; export type DeviceBindCallback = (data: DeviceBindRes) => void; export type DeviceListCallback = (data: IDevice[]) => void; export interface GizDeviceDataItem { [keyof: string]: number | Array | boolean; } export interface GizDeviceData { sn: number; cmd: number; data: GizDeviceDataItem; alerts: GizDeviceDataItem; faults: GizDeviceDataItem; } export interface GizDeviceInfoProfile { moduleHardVersion: string; moduleSoftVersion: string; mcuHardVersion: string; mcuSoftVersion: string; protocolVersion: string; serialPortprotocolVersion: string; reserve1: string; reserve2: string; productKey: string; hardwareInfo: string; } export type GizTimerSyncStatus = 0 | 1 | 2; export interface GizDeviceLocalTimerItem { ctime: String; id: number; taskId: number; repeat: [number]; date: string; time: string; syncStatus: GizTimerSyncStatus; attr: Object; } export interface GizDeviceLocalTimerParams { taskId: number; attr: Object; repeat: [number]; date: string; time: string; }