interface.uts 2.2 KB
Newer Older
杜庆泉's avatar
杜庆泉 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
/**
 * Wifi 函数通用入参封装
 */
 export type WifiOption = {
	success?: (res: UniWifiResult) => void;
	fail?: (res: UniWifiResult) => void;
	complete?: (res: UniWifiResult) => void;
};

/**
 * Wifi 链接参数封装 
 */
export type WifiConnectOption = {
	SSID?: string;
	BSSID?: string;
	password?: string;
	maunal?: boolean;
	partialInfo?: boolean; //ios不生效
	success?: (res: UniWifiResult) => void;
	fail?: (res: UniWifiResult) => void;
	complete?: (res: UniWifiResult) => void;
}

/**
 * 获取当前链接的wifi信息
 */
export type GetConnectedWifiOptions = {
	partialInfo?: boolean
	success?: (res: UniWifiResult) => void
	fail?: (res: UniWifiResult) => void
	complete?: (res: UniWifiResult) => void
}

/* 
 * 对外暴露的wifi信息
 */
export type UniWifiInfo = {
	SSID: string;
	BSSID?: string;
	secure?: boolean;
	signalStrength?: number;
	frequency?: number;
}


export type UniWifiResult = {
	errCode : number,
	errSubject : string,
	errMsg : string,
	wifi: UniWifiInfo | null
}

export type UniWifiCallback = () => void


export type StartWifi = (option: WifiOption) => void

export type StopWifi = (option: WifiOption) => void

export type GetWifiList = (option: WifiOption) => void

export type OnGetWifiList = (callback: UniWifiCallback) => void

export type OffGetWifiList = (callback: UniWifiCallback) => void

export type GetConnectedWifi = (option: GetConnectedWifiOptions) => void

export type ConnectWifi = (option: WifiConnectOption) => void

export type OnWifiConnected = (callback: UniWifiCallback) => void

export type OnWifiConnectedWithPartialInfo = (callback: UniWifiCallback) => void

export type OffWifiConnected = (callback: UniWifiCallback | null) => void

export type OnOffWifiConnectedWithPartialInfo = (callback: UniWifiCallback | null) => void

export type SetWifiList = (option: WifiOption) => void

interface Uni {
	startWifi : StartWifi,
	stopWifi : StopWifi,
	getWifiList : GetWifiList,
	onGetWifiList : OnGetWifiList,
	offGetWifiList : OffGetWifiList,
	getConnectedWifi : GetConnectedWifi,
	onWifiConnected : OnWifiConnected,
	onWifiConnectedWithPartialInfo : OnWifiConnectedWithPartialInfo,
	offWifiConnected : OffWifiConnected,
	onOffWifiConnectedWithPartialInfo : OnOffWifiConnectedWithPartialInfo,
	setWifiList : SetWifiList,
}