var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
import { sleep } from '@iotize/common/utility';
import { BleComError } from '@iotize/tap/protocol/ble/common';
import { BleConfig } from '@iotize/tap/protocol/ble/common';
export class MockPeripheralAdapter {
    constructor(options = { state: 'connected', connectDelay: 100, disconnectDelay: 100 }) {
        this.options = options;
        this.services = {};
        this.services[BleConfig.services.lwm2m.service] = new MockServiceAdapter(BleConfig.services.lwm2m.service);
        this.services[BleConfig.services.fastLwm2m.service] = new MockServiceAdapter(BleConfig.services.lwm2m.service);
    }
    get state() {
        return this.options.state;
    }
    connect() {
        return __awaiter(this, void 0, void 0, function* () {
            yield sleep(this.options.connectDelay);
        });
    }
    disconnect() {
        return __awaiter(this, void 0, void 0, function* () {
            yield sleep(this.options.disconnectDelay);
        });
    }
    discoverServices() {
        return __awaiter(this, void 0, void 0, function* () {
            return this.services;
        });
    }
    getService(uuid) {
        return __awaiter(this, void 0, void 0, function* () {
            if (!(uuid in this.services)) {
                throw BleComError.serviceNotFound(uuid);
            }
            return this.services[uuid];
        });
    }
}
export class MockServiceAdapter {
    constructor(uuid) {
        this.uuid = uuid;
    }
    getCharacteristic() {
        throw new Error(`Not implemented yet`);
    }
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9jay1wZXJpcGhlcmFsLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQGlvdGl6ZS90YXAvcHJvdG9jb2wvYmxlL3Rlc3RpbmcvIiwic291cmNlcyI6WyJsaWIvbW9jay1wZXJpcGhlcmFsL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