import { CodeError } from '@iotize/common/error';
export class BleComError extends CodeError {
    static invalidBleChunkChecksum(packetBuilder) {
        return InvalidBleFrameChecksum.create(packetBuilder);
    }
    static writeSizeAboveMTU(data, mtu) {
        return new BleComError(BleComError.Code.BleWriteSizeAboveMTU, `Cannot write ${data.length} bytes as it's more than the Maximal Transfert Unit (${mtu})`);
    }
    static serviceNotFound(uuid) {
        return new BleComError(BleComError.Code.BleGattServiceNotFound, `Bluetooth service with id ${uuid} not found`);
    }
    static charcacteristicNotFound(uuid) {
        return new BleComError(BleComError.Code.BleGattCharacteristicNotFound, `Bluetooth characteristic with id ${uuid} not found`);
    }
    static bleNotAvailable(msg = 'BLE is not available on your device') {
        return new BleComError(BleComError.Code.NotAvailable, msg);
    }
    static gattServerNotAvailable() {
        return new BleComError(BleComError.Code.GATTServerNotAvailable, `Generic Attribute Profile (GATT) server is not available`);
    }
    static gattServerConnectionFailed() {
        return new BleComError(BleComError.Code.GATTServerConnectionFailed, `Gatt server connection failed`);
    }
    constructor(code, msg) {
        super(msg, code);
    }
}
export class InvalidBleFrameChecksum extends BleComError {
    constructor(packetBuilder) {
        super(BleComError.Code.InvalidChecksum, `Invalid checksum`);
        this.packetBuilder = packetBuilder;
    }
    static create(packetBuilder) {
        return new InvalidBleFrameChecksum(packetBuilder);
    }
}
(function (BleComError) {
    let Code;
    (function (Code) {
        Code["InvalidChecksum"] = "InvalidChecksum";
        Code["BleGattServiceNotFound"] = "BleGattServiceNotFound";
        Code["BleGattCharacteristicNotFound"] = "BleGattCharacteristicNotFound";
        Code["BleWriteSizeAboveMTU"] = "BleWriteSizeAboveMTU";
        Code["GATTServerNotAvailable"] = "BleComErrorGATTServerNotAvailable";
        Code["GATTServerConnectionFailed"] = "BleComErrorGATTServerConnectionFailed";
        Code["NotAvailable"] = "BleComErrorNotAvailable";
    })(Code = BleComError.Code || (BleComError.Code = {}));
})(BleComError || (BleComError = {}));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJm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