var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
import { CodeError } from '@iotize/common/error';
var BleComError = /** @class */ (function (_super) {
    __extends(BleComError, _super);
    function BleComError(code, msg) {
        return _super.call(this, msg, code) || this;
    }
    BleComError.invalidBleChunkChecksum = function (packetBuilder) {
        return InvalidBleFrameChecksum.create(packetBuilder);
    };
    BleComError.writeSizeAboveMTU = function (data, mtu) {
        return new BleComError(BleComError.Code.BleWriteSizeAboveMTU, "Cannot write " + data.length + " bytes as it's more than the Maximal Transfert Unit (" + mtu + ")");
    };
    BleComError.serviceNotFound = function (uuid) {
        return new BleComError(BleComError.Code.BleGattServiceNotFound, "Bluetooth service with id " + uuid + " not found");
    };
    BleComError.charcacteristicNotFound = function (uuid) {
        return new BleComError(BleComError.Code.BleGattCharacteristicNotFound, "Bluetooth characteristic with id " + uuid + " not found");
    };
    return BleComError;
}(CodeError));
export { BleComError };
var InvalidBleFrameChecksum = /** @class */ (function (_super) {
    __extends(InvalidBleFrameChecksum, _super);
    function InvalidBleFrameChecksum(packetBuilder) {
        var _this = _super.call(this, BleComError.Code.InvalidChecksum, "Invalid checksum") || this;
        _this.packetBuilder = packetBuilder;
        return _this;
    }
    InvalidBleFrameChecksum.create = function (packetBuilder) {
        return new InvalidBleFrameChecksum(packetBuilder);
    };
    return InvalidBleFrameChecksum;
}(BleComError));
export { InvalidBleFrameChecksum };
(function (BleComError) {
    var Code;
    (function (Code) {
        Code["InvalidChecksum"] = "InvalidChecksum";
        Code["BleGattServiceNotFound"] = "BleGattServiceNotFound";
        Code["BleGattCharacteristicNotFound"] = "BleGattCharacteristicNotFound";
        Code["BleWriteSizeAboveMTU"] = "BleWriteSizeAboveMTU";
    })(Code = BleComError.Code || (BleComError.Code = {}));
})(BleComError || (BleComError = {}));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXJyb3JzLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQGlvdGl6ZS90YXAvcHJvdG9jb2wvYmxlL2NvbW1vbi8iLCJzb3VyY2VzIjpbImxpYi9lcnJvcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7OztBQUFBLE9BQU8sRUFBRSxTQUFTLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUlqRDtJQUFpQywrQkFBMkI7SUEyQnhELHFCQUFZLElBQXNCLEVBQUUsR0FBVztlQUMzQyxrQkFBTSxHQUFHLEVBQUUsSUFBSSxDQUFDO0lBQ3BCLENBQUM7SUEzQk0sbUNBQXVCLEdBQTlCLFVBQStCLGFBQStCO1FBQzFELE9BQU8sdUJBQXVCLENBQUMsTUFBTSxDQUFDLGFBQWEsQ0FBQyxDQUFDO0lBQ3pELENBQUM7SUFDTSw2QkFBaUIsR0FBeEIsVUFBeUIsSUFBZ0IsRUFBRSxHQUFXO1FBQ2xELE9BQU8sSUFBSSxXQUFXLENBQ2xCLFdBQVcsQ0FBQyxJQUFJLENBQUMsb0JBQW9CLEVBQ3JDLGtCQUFnQixJQUFJLENBQUMsTUFBTSw2REFBd0QsR0FBRyxNQUFHLENBQzVGLENBQUM7SUFDTixDQUFDO0lBRWEsMkJBQWUsR0FBN0IsVUFBOEIsSUFBWTtRQUN0QyxPQUFPLElBQUksV0FBVyxDQUNsQixXQUFXLENBQUMsSUFBSSxDQUFDLHNCQUFzQixFQUN2QywrQkFBNkIsSUFBSSxlQUFZLENBQ2hELENBQUE7SUFDTCxDQUFDO0lBRWEsbUNBQXVCLEdBQXJDLFVBQXNDLElBQVk7UUFDOUMsT0FBTyxJQ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