theta-ble-client-react-native
Version:
This library provides a way to control RICOH THETA using
161 lines (150 loc) • 5.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.CameraControlCommandV2 = void 0;
var _thetaService = require("./theta-service");
var _values = require("./values");
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); }
const MESSAGE_NO_ARGUMENT = 'No Argument.';
/* eslint no-useless-catch: 0 */
/**
* Camera Control Command V2 Service
*
* Service: B6AC7A7E-8C01-4A52-B188-68D53DF53EA2
*/
class CameraControlCommandV2 extends _thetaService.ThetaService {
constructor(device) {
super();
this.service = _values.BleServiceEnum.CAMERA_CONTROL_COMMAND_V2;
this.device = device;
}
/**
* Acquires basic information of the camera and supported functions.
*
* Characteristic: A0452E2D-C7D8-4314-8CD6-7B8BBAB4D523
*
* @returns Static attributes of Theta.
*/
async getInfo() {
try {
return await ThetaBleClient.nativeCameraControlCommandV2GetInfo(this.device.id);
} catch (error) {
throw error;
}
}
/**
* Acquires the camera states.
*
* Characteristic: 083D92B0-21E0-4FB2-9503-7D8B2C2BB1D1
*
* @returns Mutable values representing Theta status.
*/
async getState() {
try {
return await ThetaBleClient.nativeCameraControlCommandV2GetState(this.device.id);
} catch (error) {
throw error;
}
}
/**
* Set camera state notification.
*
* Characteristic: D32CE140-B0C2-4C07-AF15-2301B5057B8C
*
* @param callback Notification function
*/
async setStateNotify(callback) {
try {
await ThetaBleClient.nativeCameraControlCommandV2SetStateNotify(this.device.id, callback ? true : false);
this.device.notifyList.set('NOTIFY_STATE', callback ? event => {
callback(event.params, event.error);
} : undefined);
} catch (error) {
throw error;
}
}
/**
* Acquires the camera states.
*
* Characteristic: 8881CE4E-96FC-4C6C-8103-5DDA0AD138FB
*
* @returns Mutable values representing Theta status.
*/
async getState2() {
try {
return await ThetaBleClient.nativeCameraControlCommandV2GetState2(this.device.id);
} catch (error) {
throw error;
}
}
/**
* Acquires the properties and property support specifications for shooting, the camera, etc.
*
* Characteristic: 7CFFAAE3-8467-4D0C-A9DD-7F70B4F52863
*
* @param optionNames List of [OptionName]
* @return Options acquired
*/
async getOptions(optionNames) {
if (optionNames.length === 0) {
throw new Error(MESSAGE_NO_ARGUMENT);
}
try {
return await ThetaBleClient.nativeCameraControlCommandV2GetOptions(this.device.id, optionNames ?? []);
} catch (error) {
throw error;
}
}
/**
* Acquires the properties and property support specifications for shooting, the camera, etc.
*
* Characteristic: 7CFFAAE3-8467-4D0C-A9DD-7F70B4F52863
*
* @param optionNames List of strings representing the names of the options
* @return A map where each key is an option name and each value is the corresponding value for that option.
*/
async getOptionsByString(optionNames) {
if (optionNames.length === 0) {
throw new Error(MESSAGE_NO_ARGUMENT);
}
try {
return await ThetaBleClient.nativeCameraControlCommandV2GetOptionsByString(this.device.id, optionNames ?? []);
} catch (error) {
throw error;
}
}
/**
* Property settings for shooting, the camera, etc.
*
* Characteristic: F0BCD2F9-5862-4653-B50D-80DC51E8CB82
*
* @param options Camera setting options
*/
async setOptions(options) {
try {
return await ThetaBleClient.nativeCameraControlCommandV2SetOptions(this.device.id, options);
} catch (error) {
throw error;
}
}
/**
* Release shutter
*
* If CaptureMode is IMAGE, perform `camera.takePicture`
* If CaptureMode is VIDEO, and CaptureState is IDLE, then `camera.startCapture` is executed
* If CaptureMode is VIDEO, and CaptureStatus is SHOOTING, then `camera.stopCapture` is executed
*
* Characteristic: 6E2DEEBE-88B0-42A5-829D-1B2C6ABCE750
*/
async releaseShutter() {
try {
return await ThetaBleClient.nativeCameraControlCommandV2ReleaseShutter(this.device.id);
} catch (error) {
throw error;
}
}
}
exports.CameraControlCommandV2 = CameraControlCommandV2;
//# sourceMappingURL=camera-control-command-v2.js.map