theta-ble-client-react-native
Version:
This library provides a way to control RICOH THETA using
89 lines (80 loc) • 1.98 kB
JavaScript
import { ThetaDevice } from '../theta-device';
import * as ThetaBleClient from '../native';
/**
* scan properties
*/
async function scanImpl(name, timeout) {
/* eslint-disable-next-line no-useless-catch */
try {
const deviceList = await ThetaBleClient.nativeScan({
name,
timeout
});
const result = deviceList.map(element => {
return new ThetaDevice(element.deviceId, element.name);
});
return result;
} catch (error) {
throw error;
}
}
/**
* Scan for nearby THETA.
*
* Call {@link ThetaDevice.release} when the use of the acquired {@link ThetaDevice} is complete.
*
* @param props scan properties.
* @returns Found THETA. If no name is specified, an array is returned.
*/
/**
* Deprecated
* Scan for nearby THETA.
*
* Call {@link ThetaDevice.release} when the use of the acquired {@link theta-device.ThetaDevice} is complete.
*
* @param name Name of THETA to connect.
* @param uuid UUID used for authentication.
* @param timeout Configuration of timeout.
* @returns Found THETA
*/
export async function scan(props, timeout) {
let paramName;
let paramTimeout = timeout;
if (typeof props === 'string') {
paramName = props;
} else if (props != null) {
const {
name,
timeout
} = props;
paramName = name;
paramTimeout = timeout;
}
/* eslint-disable-next-line no-useless-catch */
try {
const result = await scanImpl(paramName, paramTimeout);
if (typeof paramName === 'string') {
return result.length === 0 ? undefined : result[0];
} else {
return result;
}
} catch (error) {
throw error;
}
}
/**
* scan SSID properties
*/
/**
* SSID and default password
*/
/**
* Scan for nearby THETA SSID.
*
* @param params scan SSID properties.
* @returns Found THETA SSID list.
*/
export async function scanThetaSsid(params) {
return ThetaBleClient.nativeScanThetaSsid(params ?? {});
}
//# sourceMappingURL=theta-ble.js.map