"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AsyncBC = exports.AsyncBCRef = exports.AsyncBCWatch = exports.AsyncBCCall = exports.AsyncBCGet = void 0;
const MethodNotImplementedError_1 = require("../../../exception/MethodNotImplementedError");
const AsyncBCGet = (characteristic) => ({
    $readValue: async function ({}, callback) {
        try {
            const value = await characteristic.readValue();
            callback(value);
        }
        catch (err) {
            callback(undefined, err.message);
        }
    },
});
exports.AsyncBCGet = AsyncBCGet;
const AsyncBCCall = (characteristic) => {
    return {
        async $writeValue({ value }, callback) {
            try {
                await characteristic.writeValue(value);
                callback();
            }
            catch (err) {
                callback(undefined, err.message);
            }
        },
    };
};
exports.AsyncBCCall = AsyncBCCall;
const AsyncBCWatch = (characteristic) => {
    return {};
};
exports.AsyncBCWatch = AsyncBCWatch;
const AsyncBCRef = (characteristic) => ({
    $getCharacteristic: function (data) {
        throw new MethodNotImplementedError_1.MethodNotImplementedError();
    },
});
exports.AsyncBCRef = AsyncBCRef;
const AsyncBC = (characteristic) => {
    return {
        ...(0, exports.AsyncBCGet)(characteristic),
        ...(0, exports.AsyncBCCall)(characteristic),
        ...(0, exports.AsyncBCWatch)(characteristic),
        ...(0, exports.AsyncBCRef)(characteristic),
    };
};
exports.AsyncBC = AsyncBC;
//# sourceMappingURL=AsyncBC.js.map