theta-ble-client-react-native
Version:
This library provides a way to control RICOH THETA using
96 lines (87 loc) • 2.76 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.scan = scan;
exports.scanThetaSsid = scanThetaSsid;
var _thetaDevice = require("../theta-device");
var ThetaBleClient = _interopRequireWildcard(require("../native"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/**
* 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.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
*/
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.
*/
async function scanThetaSsid(params) {
return ThetaBleClient.nativeScanThetaSsid(params ?? {});
}
//# sourceMappingURL=theta-ble.js.map