Skip to content

Commit

Permalink
feat: change api name & update documents
Browse files Browse the repository at this point in the history
  • Loading branch information
seojinwoo committed Oct 11, 2022
1 parent f4f5b8e commit a8a2cc4
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/iot-device-sdk/src/common.ts
Expand Up @@ -8,6 +8,7 @@ export type RegisterGwParam = {
timeout: number;
};

/** @hidden */
export type RemoveDeviceParams = {
devId: string;
};
Expand Down Expand Up @@ -481,7 +482,7 @@ export class TuyaSdkBridge {
}

// Get Token for Activator Wifi Ap Device
public static async getTokenForWifiAp(): Promise<any> {
public static async reqTokenForWifiAp(): Promise<any> {
let returnValue: any;
let errorOccur = false;

Expand Down
2 changes: 1 addition & 1 deletion packages/iot-device-sdk/src/index.ts
Expand Up @@ -3,4 +3,4 @@ export * from './common';
export { init, init_v2, removeDevice } from './core';
export { startSearchWiredGW, stopSearchWiredGW, registerWiredGW } from './wiredGw';
export { startRegisterZigbeeSubDevice, stopRegisterZigbeeSubDevice } from './subDevice';
export { registerWifiEzDevice } from './wifiDevice';
export { registerWifiEzDevice, registerWifiApDevice, reqTokenForWifiAp } from './wifiDevice';
61 changes: 61 additions & 0 deletions packages/iot-device-sdk/src/wifiDevice.ts
Expand Up @@ -35,3 +35,64 @@ import { TuyaSdkBridge } from './common';
export async function registerWifiEzDevice(ssid: string, password: string, timeout: number): Promise<any> {
return TuyaSdkBridge.registerWifiEzDevice(ssid, password, timeout);
}

/**
* Register wifi device by AP Mode <br/>
* In case success registration, Thing name is made by combination(building/dong/ho/user (zGuard meta info.)
*
* @param ssid - The name of the Wi-Fi network to which a paired device is connected
* @param password - The password of the Wi-Fi network to which a paired device is connected
* @param timeout - maximum timeout for wifi devices registration, unit is seconds
* @param token - token value from {@link reqTokenForWifiAp}
*
* @returns Success and failure details as a result
* - in case OK: [ref](https://github.com/iot-device-sdk/blob/main/packages/iot-device-sdk/sample-gw.md)
* - in case Processing: registerWifiEzDevice is started
* - in case Occur Timeout: Timeout
* @example
* ```ts
* iot-device-sdk.registerWifiApDevice(
* "ssid",
* "password",
* 90,
* "token"
* ).then(
* (okRes: any) => {
* debugText("Ok Res")
* assignedWifiDevId = okRes.devId
* console.log("DevID: " + assignedWifiDevId)
* },
* (errRes) => {
* debugText("Ng Res")
* console.log(errRes)
* }
* )
* ```
*/
export async function registerWifiApDevice(ssid: string, password: string, timeout: number, token:string): Promise<any> {
return TuyaSdkBridge.registerWifiApDevice(ssid, password, timeout, token);
}


/**
* Request token to device register <br/>
* This api is used for {@link registerWifiApDevice}
*
* @returns Success and failure details as a result
* - in case OK: token string
* - in case NG: error message
* @example
* ```ts
* iot-device-sdk.reqTokenForWifiAp().then(
* (okRes: any) => {
* console.log("Token: " + okRes)
* },
* (errRes) => {
* console.log(errRes)
* }
* )
* ```
*/
export async function reqTokenForWifiAp(): Promise<string> {
return TuyaSdkBridge.reqTokenForWifiAp();
}

0 comments on commit a8a2cc4

Please sign in to comment.