Search in sources :

Example 6 with BleDisconnectedException

use of com.polidea.rxandroidble2.exceptions.BleDisconnectedException in project xDrip by NightscoutFoundation.

the class BlueJayService method sendOtaChunk.

boolean sendOtaChunk(final UUID uuid, final byte[] bytes) {
    if (I.connection == null || !I.isConnected)
        return false;
    I.connection.writeCharacteristic(uuid, bytes).observeOn(Schedulers.io()).subscribeOn(Schedulers.io()).subscribe(characteristicValue -> {
        if (D)
            UserError.Log.d(TAG, "Wrote record request request: " + bytesToHex(characteristicValue));
        busy = false;
    }, throwable -> {
        UserError.Log.e(TAG, "Failed to write record request: " + throwable);
        if (throwable instanceof BleGattCharacteristicException) {
            final int status = ((BleGattCharacteristicException) throwable).getStatus();
            UserError.Log.e(TAG, "Got status message: " + Helper.getStatusName(status));
        } else {
            if (throwable instanceof BleDisconnectedException) {
                changeState(CLOSE);
            }
            UserError.Log.d(TAG, "Throwable in Record End write: " + throwable);
        }
    });
    // only that we didn't fail in setup
    return true;
}
Also used : BleGattCharacteristicException(com.polidea.rxandroidble2.exceptions.BleGattCharacteristicException) BleDisconnectedException(com.polidea.rxandroidble2.exceptions.BleDisconnectedException) SuppressLint(android.annotation.SuppressLint) SlidingWindowConstraint(com.eveningoutpost.dexdrip.utils.time.SlidingWindowConstraint)

Example 7 with BleDisconnectedException

use of com.polidea.rxandroidble2.exceptions.BleDisconnectedException in project xDrip by NightscoutFoundation.

the class InPenService method getRecords.

private void getRecords(final int firstIndex, final int lastIndex) {
    final int numberOfRecords = lastIndex - firstIndex;
    if (numberOfRecords > 30) {
        I.connection.writeCharacteristic(KEEPALIVE, new KeepAliveTx().getBytes()).subscribe(value -> {
            UserError.Log.d(TAG, "Wrote keep alive for " + numberOfRecords);
        }, throwable -> {
            UserError.Log.d(TAG, "Got exception in keep alive" + throwable);
        });
    }
    final RecordTx packet = new RecordTx(firstIndex, lastIndex);
    UserError.Log.d(TAG, "getRecords called, loading: " + firstIndex + " to " + lastIndex);
    I.connection.setupIndication(RECORD_INDICATE).doOnNext(notificationObservable -> {
        I.connection.writeCharacteristic(RECORD_START, packet.startBytes()).subscribe(valueS -> {
            UserError.Log.d(TAG, "Wrote record start: " + bytesToHex(valueS));
            I.connection.writeCharacteristic(RECORD_END, packet.endBytes()).subscribe(valueE -> {
                UserError.Log.d(TAG, "Wrote record end: " + bytesToHex(valueE));
                I.connection.writeCharacteristic(RECORD_REQUEST, packet.triggerBytes()).subscribe(characteristicValue -> {
                    if (D)
                        UserError.Log.d(TAG, "Wrote record request request: " + bytesToHex(characteristicValue));
                }, throwable -> {
                    UserError.Log.e(TAG, "Failed to write record request: " + throwable);
                    if (throwable instanceof BleGattCharacteristicException) {
                        final int status = ((BleGattCharacteristicException) throwable).getStatus();
                        UserError.Log.e(TAG, "Got status message: " + Helper.getStatusName(status));
                    }
                });
            }, throwable -> {
                UserError.Log.d(TAG, "Throwable in Record End write: " + throwable);
            });
        }, throwable -> {
            UserError.Log.d(TAG, "Throwable in Record Start write: " + throwable);
        // throws BleGattCharacteristicException status = 128 for "no resources" eg nothing matches
        });
    }).flatMap(notificationObservable -> notificationObservable).timeout(120, TimeUnit.SECONDS).observeOn(Schedulers.newThread()).subscribe(bytes -> {
        records.add(bytes);
        UserError.Log.d(TAG, "INDICATE INDICATE: " + HexDump.dumpHexString(bytes));
    }, throwable -> {
        if (!(throwable instanceof OperationSuccess)) {
            if (throwable instanceof BleDisconnectedException) {
                UserError.Log.d(TAG, "Disconnected when waiting to receive indication: " + throwable);
            } else {
                UserError.Log.e(TAG, "Error receiving indication: " + throwable);
            }
            Inevitable.task("check-records-queue", 100, this::processRecordsQueue);
        }
    });
}
Also used : KeepAliveTx(com.eveningoutpost.dexdrip.insulin.inpen.messages.KeepAliveTx) Arrays(java.util.Arrays) TypeToken(com.google.gson.reflect.TypeToken) AdvertRx(com.eveningoutpost.dexdrip.insulin.inpen.messages.AdvertRx) ProcessPenData(com.eveningoutpost.dexdrip.insulin.shared.ProcessPenData) GsonBuilder(com.google.gson.GsonBuilder) Inevitable(com.eveningoutpost.dexdrip.UtilityModels.Inevitable) Pref(com.eveningoutpost.dexdrip.UtilityModels.Pref) HexDump.dumpHexString(com.eveningoutpost.dexdrip.ImportedLibraries.usbserial.util.HexDump.dumpHexString) Map(java.util.Map) BleGattCharacteristicException(com.polidea.rxandroidble2.exceptions.BleGattCharacteristicException) TargetApi(android.annotation.TargetApi) INFO_CHARACTERISTICS(com.eveningoutpost.dexdrip.insulin.inpen.Constants.INFO_CHARACTERISTICS) RECORD_INDEX(com.eveningoutpost.dexdrip.insulin.inpen.Constants.RECORD_INDEX) DEFAULT_BOND_UNITS(com.eveningoutpost.dexdrip.insulin.inpen.InPen.DEFAULT_BOND_UNITS) RECORD_REQUEST(com.eveningoutpost.dexdrip.insulin.inpen.Constants.RECORD_REQUEST) JoH(com.eveningoutpost.dexdrip.Models.JoH) JoH.bytesToHex(com.eveningoutpost.dexdrip.Models.JoH.bytesToHex) BOND_NONE(android.bluetooth.BluetoothDevice.BOND_NONE) STORE_INPEN_ADVERT(com.eveningoutpost.dexdrip.insulin.inpen.InPen.STORE_INPEN_ADVERT) RecordRx(com.eveningoutpost.dexdrip.insulin.inpen.messages.RecordRx) BATTERY(com.eveningoutpost.dexdrip.insulin.inpen.Constants.BATTERY) PenData(com.eveningoutpost.dexdrip.Models.PenData) STORE_INPEN_BATTERY(com.eveningoutpost.dexdrip.insulin.inpen.InPen.STORE_INPEN_BATTERY) BluetoothGattCharacteristic(android.bluetooth.BluetoothGattCharacteristic) WakeLockTrampoline(com.eveningoutpost.dexdrip.utils.framework.WakeLockTrampoline) BatteryRx(com.eveningoutpost.dexdrip.insulin.inpen.messages.BatteryRx) GOOD(com.eveningoutpost.dexdrip.UtilityModels.StatusItem.Highlight.GOOD) BONDCONTROL(com.eveningoutpost.dexdrip.insulin.inpen.Constants.BONDCONTROL) HexDump(com.eveningoutpost.dexdrip.ImportedLibraries.usbserial.util.HexDump) ArrayList(java.util.ArrayList) BOND_AUTHORITY(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.BOND_AUTHORITY) Helper(com.eveningoutpost.dexdrip.utils.bt.Helper) Observable(io.reactivex.Observable) JamBaseBluetoothSequencer(com.eveningoutpost.dexdrip.Services.JamBaseBluetoothSequencer) RxBleDeviceServices(com.polidea.rxandroidble2.RxBleDeviceServices) BONDAGE(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.BONDAGE) BondTx(com.eveningoutpost.dexdrip.insulin.inpen.messages.BondTx) Converters(com.eveningoutpost.dexdrip.utils.math.Converters) JoH.ratelimit(com.eveningoutpost.dexdrip.Models.JoH.ratelimit) JoH.quietratelimit(com.eveningoutpost.dexdrip.Models.JoH.quietratelimit) RecordTx(com.eveningoutpost.dexdrip.insulin.inpen.messages.RecordTx) RECORD_END(com.eveningoutpost.dexdrip.insulin.inpen.Constants.RECORD_END) GET_AUTH_STATE(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.GET_AUTH_STATE) UserError(com.eveningoutpost.dexdrip.Models.UserError) PersistentStore(com.eveningoutpost.dexdrip.UtilityModels.PersistentStore) HEXDUMP_INFO_CHARACTERISTICS(com.eveningoutpost.dexdrip.insulin.inpen.Constants.HEXDUMP_INFO_CHARACTERISTICS) InPenEntry.isStarted(com.eveningoutpost.dexdrip.insulin.inpen.InPenEntry.isStarted) PendingIntent(android.app.PendingIntent) INIT(com.eveningoutpost.dexdrip.Services.JamBaseBluetoothSequencer.BaseState.INIT) PEN_ATTACH_TIME(com.eveningoutpost.dexdrip.insulin.inpen.Constants.PEN_ATTACH_TIME) GET_BATTERY(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.GET_BATTERY) PowerManager(android.os.PowerManager) StatusItem(com.eveningoutpost.dexdrip.UtilityModels.StatusItem) KEEP_ALIVE(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.KEEP_ALIVE) Gson(com.google.gson.Gson) Schedulers(io.reactivex.schedulers.Schedulers) GET_INDEX(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.GET_INDEX) BAD(com.eveningoutpost.dexdrip.UtilityModels.StatusItem.Highlight.BAD) GET_RECORDS(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.GET_RECORDS) INPEN_SERVICE_FAILOVER_ID(com.eveningoutpost.dexdrip.UtilityModels.Constants.INPEN_SERVICE_FAILOVER_ID) CLOSE(com.eveningoutpost.dexdrip.Services.JamBaseBluetoothSequencer.BaseState.CLOSE) NORMAL(com.eveningoutpost.dexdrip.UtilityModels.StatusItem.Highlight.NORMAL) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) KEEPALIVE(com.eveningoutpost.dexdrip.insulin.inpen.Constants.KEEPALIVE) Helper.getCharactersticName(com.eveningoutpost.dexdrip.utils.bt.Helper.getCharactersticName) UUID(java.util.UUID) GET_TIME(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.GET_TIME) List(java.util.List) Disposable(io.reactivex.disposables.Disposable) BleDisconnectedException(com.polidea.rxandroidble2.exceptions.BleDisconnectedException) R(com.eveningoutpost.dexdrip.R) REMAINING_INDEX(com.eveningoutpost.dexdrip.insulin.inpen.Constants.REMAINING_INDEX) Queue(java.util.Queue) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) BluetoothDevice(android.bluetooth.BluetoothDevice) GET_AUTH_STATE2(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.GET_AUTH_STATE2) RECORD_INDICATE(com.eveningoutpost.dexdrip.insulin.inpen.Constants.RECORD_INDICATE) Intent(android.content.Intent) HashMap(java.util.HashMap) GET_A_TIME(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.GET_A_TIME) JoH.dateTimeText(com.eveningoutpost.dexdrip.Models.JoH.dateTimeText) JoH.hourMinuteString(com.eveningoutpost.dexdrip.Models.JoH.hourMinuteString) Scheduler(io.reactivex.Scheduler) BleGattException(com.polidea.rxandroidble2.exceptions.BleGattException) ID_INPEN(com.eveningoutpost.dexdrip.insulin.inpen.InPenEntry.ID_INPEN) STORE_INPEN_INFOS(com.eveningoutpost.dexdrip.insulin.inpen.InPen.STORE_INPEN_INFOS) Build(android.os.Build) TimeRx(com.eveningoutpost.dexdrip.insulin.inpen.messages.TimeRx) SlidingWindowConstraint(com.eveningoutpost.dexdrip.utils.time.SlidingWindowConstraint) AUTHENTICATION(com.eveningoutpost.dexdrip.insulin.inpen.Constants.AUTHENTICATION) PRINTABLE_INFO_CHARACTERISTICS(com.eveningoutpost.dexdrip.insulin.inpen.Constants.PRINTABLE_INFO_CHARACTERISTICS) JoH.emptyString(com.eveningoutpost.dexdrip.Models.JoH.emptyString) BluetoothGattService(android.bluetooth.BluetoothGattService) PEN_TIME(com.eveningoutpost.dexdrip.insulin.inpen.Constants.PEN_TIME) RECORD_START(com.eveningoutpost.dexdrip.insulin.inpen.Constants.RECORD_START) GET_IDENTITY(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.GET_IDENTITY) JoH.msSince(com.eveningoutpost.dexdrip.Models.JoH.msSince) TimeUnit(java.util.concurrent.TimeUnit) BOND_BONDED(android.bluetooth.BluetoothDevice.BOND_BONDED) KeepAliveTx(com.eveningoutpost.dexdrip.insulin.inpen.messages.KeepAliveTx) SECOND_IN_MS(com.eveningoutpost.dexdrip.UtilityModels.Constants.SECOND_IN_MS) MINUTE_IN_MS(com.eveningoutpost.dexdrip.UtilityModels.Constants.MINUTE_IN_MS) BleGattCharacteristicException(com.polidea.rxandroidble2.exceptions.BleGattCharacteristicException) RecordTx(com.eveningoutpost.dexdrip.insulin.inpen.messages.RecordTx) BleDisconnectedException(com.polidea.rxandroidble2.exceptions.BleDisconnectedException) SlidingWindowConstraint(com.eveningoutpost.dexdrip.utils.time.SlidingWindowConstraint)

Example 8 with BleDisconnectedException

use of com.polidea.rxandroidble2.exceptions.BleDisconnectedException in project xDrip by NightscoutFoundation.

the class MiBandService method authPhase.

@SuppressLint("CheckResult")
private void authPhase() {
    extendWakeLock(30000);
    RxBleConnection connection = I.connection;
    if (d)
        UserError.Log.d(TAG, "Authorizing");
    if (I.connection == null) {
        if (d)
            UserError.Log.d(TAG, "Cannot enable as connection is null!");
        return;
    }
    String authKey = MiBand.getPersistentAuthKey();
    if (MiBand.getMibandType() == MI_BAND4) {
        if (authKey.isEmpty()) {
            authKey = MiBand.getAuthKey();
            if (authKey.isEmpty()) {
                authKey = AuthMessages.getAuthCodeFromFilesSystem(MiBand.getMac());
            }
            if (!AuthMessages.isValidAuthKey(authKey)) {
                JoH.static_toast_long("Wrong miband authorization key, please recheck a key and try to reconnect again");
                changeState(AUTHORIZE_FAILED);
                return;
            } else {
                MiBand.setAuthKey(authKey);
            }
        }
    }
    if (!AuthMessages.isValidAuthKey(authKey)) {
        authKey = "";
    }
    if (d)
        UserError.Log.d(TAG, "authKey: " + authKey);
    authorisation = new AuthMessages(MiBand.getMibandType(), authKey);
    if (d)
        UserError.Log.d(TAG, "localKey: " + JoH.bytesToHex(authorisation.getLocalKey()));
    authSubscription = new Subscription(connection.setupNotification(authorisation.getCharacteristicUUID()).timeout(20, // WARN
    TimeUnit.SECONDS).doOnNext(notificationObservable -> {
        if (d)
            UserError.Log.d(TAG, "Notification for auth enabled");
        if (MiBand.isAuthenticated()) {
            // get random key from band
            connection.writeCharacteristic(authorisation.getCharacteristicUUID(), authorisation.getAuthKeyRequest()).subscribe(val -> {
                if (d)
                    UserError.Log.d(TAG, "Wrote getAuthKeyRequest: " + JoH.bytesToHex(val));
            }, throwable -> {
                UserError.Log.e(TAG, "Could not getAuthKeyRequest: " + throwable);
            });
        } else {
            connection.writeCharacteristic(authorisation.getCharacteristicUUID(), authorisation.getAuthCommand()).subscribe(characteristicValue -> {
                UserError.Log.d(TAG, "Wrote getAuthCommand, got: " + JoH.bytesToHex(characteristicValue));
            }, throwable -> {
                UserError.Log.e(TAG, "Could not write getAuthCommand: " + throwable);
            });
        }
    }).flatMap(notificationObservable -> notificationObservable).subscribe(bytes -> {
        // incoming notifications
        if (d)
            UserError.Log.d(TAG, "Received auth notification bytes: " + bytesToHex(bytes));
        ProcessAuthCommands(connection, bytes);
    // changeNextState();
    }, throwable -> {
        UserError.Log.d(TAG, "Throwable in Record Notification: " + throwable);
        if (throwable instanceof BleCharacteristicNotFoundException) {
            // maybe legacy - ignore for now but needs better handling
            UserError.Log.d(TAG, "Characteristic not found for notification");
        } else if (throwable instanceof BleCannotSetCharacteristicNotificationException) {
            UserError.Log.e(TAG, "Problems setting notifications - disconnecting");
        } else if (throwable instanceof BleDisconnectedException) {
            UserError.Log.d(TAG, "Disconnected while enabling notifications");
        } else if (throwable instanceof TimeoutException) {
            // check if it is normal timeout
            if (!MiBand.isAuthenticated()) {
                String errorText = "MiBand authentication failed due to authentication timeout. When your Mi Band vibrates and blinks, tap it a few times in a row.";
                UserError.Log.d(TAG, errorText);
                JoH.static_toast_long(errorText);
            }
        }
        if (authSubscription != null) {
            authSubscription.unsubscribe();
        }
        changeState(CLOSE);
    }));
}
Also used : AuthMessages(com.eveningoutpost.dexdrip.watch.miband.message.AuthMessages) AUTHORIZE_FAILED(com.eveningoutpost.dexdrip.watch.miband.MiBandService.MiBandState.AUTHORIZE_FAILED) AUTH_REQUEST_RANDOM_AUTH_NUMBER(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes.AUTH_REQUEST_RANDOM_AUTH_NUMBER) AuthMessages(com.eveningoutpost.dexdrip.watch.miband.message.AuthMessages) Arrays(java.util.Arrays) com.eveningoutpost.dexdrip.xdrip(com.eveningoutpost.dexdrip.xdrip) Date(java.util.Date) TimeoutException(java.util.concurrent.TimeoutException) PendingIntent(android.app.PendingIntent) CLOSED(com.eveningoutpost.dexdrip.Services.JamBaseBluetoothSequencer.BaseState.CLOSED) INIT(com.eveningoutpost.dexdrip.Services.JamBaseBluetoothSequencer.BaseState.INIT) Inevitable(com.eveningoutpost.dexdrip.UtilityModels.Inevitable) BleCannotSetCharacteristicNotificationException(com.polidea.rxandroidble2.exceptions.BleCannotSetCharacteristicNotificationException) PowerManager(android.os.PowerManager) HeartRate(com.eveningoutpost.dexdrip.Models.HeartRate) StatusItem(com.eveningoutpost.dexdrip.UtilityModels.StatusItem) BleCharacteristicNotFoundException(com.polidea.rxandroidble2.exceptions.BleCharacteristicNotFoundException) COMMAND_ACK_FIND_PHONE_IN_PROGRESS(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes.COMMAND_ACK_FIND_PHONE_IN_PROGRESS) AUTH_FAIL(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes.AUTH_FAIL) Schedulers(io.reactivex.schedulers.Schedulers) AUTH_MIBAND4_CODE_FAIL(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes.AUTH_MIBAND4_CODE_FAIL) AUTH_RESPONSE(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes.AUTH_RESPONSE) AUTH_SEND_KEY(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes.AUTH_SEND_KEY) ActiveBgAlert(com.eveningoutpost.dexdrip.Models.ActiveBgAlert) FeaturesControllMessage(com.eveningoutpost.dexdrip.watch.miband.message.FeaturesControllMessage) MIBAND_NOTIFY_TYPE_ALARM(com.eveningoutpost.dexdrip.watch.miband.Const.MIBAND_NOTIFY_TYPE_ALARM) CLOSE(com.eveningoutpost.dexdrip.Services.JamBaseBluetoothSequencer.BaseState.CLOSE) BgReading(com.eveningoutpost.dexdrip.Models.BgReading) PrefBindingFactory(com.eveningoutpost.dexdrip.watch.PrefBindingFactory) UUID(java.util.UUID) JoH.getResourceURI(com.eveningoutpost.dexdrip.Models.JoH.getResourceURI) UNKNOWN(com.eveningoutpost.dexdrip.watch.miband.MiBand.MiBandType.UNKNOWN) JoH(com.eveningoutpost.dexdrip.Models.JoH) List(java.util.List) BleDisconnectedException(com.polidea.rxandroidble2.exceptions.BleDisconnectedException) JoH.bytesToHex(com.eveningoutpost.dexdrip.Models.JoH.bytesToHex) MIBAND_NOTIFY_TYPE_CANCEL(com.eveningoutpost.dexdrip.watch.miband.Const.MIBAND_NOTIFY_TYPE_CANCEL) R(com.eveningoutpost.dexdrip.R) Subscription(com.eveningoutpost.dexdrip.utils.bt.Subscription) PREFERRED_MTU_SIZE(com.eveningoutpost.dexdrip.watch.miband.Const.PREFERRED_MTU_SIZE) AlertLevelMessage(com.eveningoutpost.dexdrip.watch.miband.message.AlertLevelMessage) JoH.msTill(com.eveningoutpost.dexdrip.Models.JoH.msTill) AUTH_SUCCESS(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes.AUTH_SUCCESS) Getter(lombok.Getter) BluetoothGattCharacteristic(android.bluetooth.BluetoothGattCharacteristic) WakeLockTrampoline(com.eveningoutpost.dexdrip.utils.framework.WakeLockTrampoline) Constants(com.eveningoutpost.dexdrip.UtilityModels.Constants) AUTH_SEND_ENCRYPTED_AUTH_NUMBER(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes.AUTH_SEND_ENCRYPTED_AUTH_NUMBER) Pair(android.util.Pair) FirmwareOperations(com.eveningoutpost.dexdrip.watch.miband.Firmware.FirmwareOperations) DisplayControllMessageMiband3_4(com.eveningoutpost.dexdrip.watch.miband.message.DisplayControllMessageMiband3_4) RxBleConnection(com.polidea.rxandroidble2.RxBleConnection) Intent(android.content.Intent) MediaPlayer(android.media.MediaPlayer) ArrayList(java.util.ArrayList) JoH.niceTimeScalar(com.eveningoutpost.dexdrip.Models.JoH.niceTimeScalar) SuppressLint(android.annotation.SuppressLint) Calendar(java.util.Calendar) DeviceEvent(com.eveningoutpost.dexdrip.watch.miband.message.DeviceEvent) DisplayControllMessageMiBand2(com.eveningoutpost.dexdrip.watch.miband.message.DisplayControllMessageMiBand2) DisplayControllMessage(com.eveningoutpost.dexdrip.watch.miband.message.DisplayControllMessage) COMMAND_DISABLE_CALL(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes.COMMAND_DISABLE_CALL) JamBaseBluetoothSequencer(com.eveningoutpost.dexdrip.Services.JamBaseBluetoothSequencer) AlertMessage(com.eveningoutpost.dexdrip.watch.miband.message.AlertMessage) MI_BAND4(com.eveningoutpost.dexdrip.watch.miband.MiBand.MiBandType.MI_BAND4) Sheduled(com.eveningoutpost.dexdrip.watch.miband.message.DisplayControllMessageMiband3_4.NightMode.Sheduled) RxBleDeviceServices(com.polidea.rxandroidble2.RxBleDeviceServices) MI_BAND2(com.eveningoutpost.dexdrip.watch.miband.MiBand.MiBandType.MI_BAND2) JoH.emptyString(com.eveningoutpost.dexdrip.Models.JoH.emptyString) SLEEP(com.eveningoutpost.dexdrip.Services.JamBaseBluetoothSequencer.BaseState.SLEEP) BluetoothGattService(android.bluetooth.BluetoothGattService) com.eveningoutpost.dexdrip.xdrip.gs(com.eveningoutpost.dexdrip.xdrip.gs) AUTH_MIBAND4_FAIL(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes.AUTH_MIBAND4_FAIL) WatchFaceGenerator(com.eveningoutpost.dexdrip.watch.miband.Firmware.WatchFaceGenerator) AlertPlayer(com.eveningoutpost.dexdrip.UtilityModels.AlertPlayer) PoorMansConcurrentLinkedDeque(com.eveningoutpost.dexdrip.utils.framework.PoorMansConcurrentLinkedDeque) TimeUnit(java.util.concurrent.TimeUnit) MIBAND_NOTIFY_TYPE_MESSAGE(com.eveningoutpost.dexdrip.watch.miband.Const.MIBAND_NOTIFY_TYPE_MESSAGE) OperationCodes(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes) UserError(com.eveningoutpost.dexdrip.Models.UserError) MIBAND_NOTIFY_TYPE_CALL(com.eveningoutpost.dexdrip.watch.miband.Const.MIBAND_NOTIFY_TYPE_CALL) BleCannotSetCharacteristicNotificationException(com.polidea.rxandroidble2.exceptions.BleCannotSetCharacteristicNotificationException) BleCharacteristicNotFoundException(com.polidea.rxandroidble2.exceptions.BleCharacteristicNotFoundException) BleDisconnectedException(com.polidea.rxandroidble2.exceptions.BleDisconnectedException) RxBleConnection(com.polidea.rxandroidble2.RxBleConnection) JoH.emptyString(com.eveningoutpost.dexdrip.Models.JoH.emptyString) Subscription(com.eveningoutpost.dexdrip.utils.bt.Subscription) TimeoutException(java.util.concurrent.TimeoutException) SuppressLint(android.annotation.SuppressLint)

Example 9 with BleDisconnectedException

use of com.polidea.rxandroidble2.exceptions.BleDisconnectedException in project xDrip by NightscoutFoundation.

the class MiBandService method installWatchface.

@SuppressLint("CheckResult")
private void installWatchface() {
    // TODO decrease display brightness before uploading watchface to minimize battery consumption
    RxBleConnection connection = I.connection;
    if (d)
        UserError.Log.d(TAG, "Install WatchFace");
    if (I.connection == null) {
        if (d)
            UserError.Log.d(TAG, "Cannot enable as connection is null!");
        return;
    }
    try {
        WatchFaceGenerator wfGen = new WatchFaceGenerator(getBaseContext().getAssets());
        byte[] fwArray = wfGen.genWatchFace();
        if (fwArray == null || fwArray.length == 0) {
            resetFirmwareState(false, "Empty image");
            return;
        }
        firmware = new FirmwareOperations(fwArray);
    } catch (Exception e) {
        resetFirmwareState(false, "FirmwareOperations error " + e.getMessage());
        return;
    }
    if (d)
        UserError.Log.d(TAG, "Begin uploading Watchface, lenght: " + firmware.getSize());
    if (d)
        UserError.Log.d(TAG, "Requesting to enable notifications for installWatchface");
    watchfaceSubscription = new Subscription(connection.setupNotification(firmware.getFirmwareCharacteristicUUID()).timeout(400, // WARN
    TimeUnit.SECONDS).doOnNext(notificationObservable -> {
        if (d)
            UserError.Log.d(TAG, "Notification for firmware enabled");
        firmware.nextSequence();
        processFirmwareCommands(null, true);
    }).flatMap(notificationObservable -> notificationObservable).subscribe(bytes -> {
        // incoming notifications
        if (d)
            UserError.Log.d(TAG, "Received firmware notification bytes: " + bytesToHex(bytes));
        processFirmwareCommands(bytes, false);
    }, throwable -> {
        UserError.Log.d(TAG, "Throwable in firmware Notification: " + throwable);
        if (throwable instanceof BleCharacteristicNotFoundException) {
            // maybe legacy - ignore for now but needs better handling
            UserError.Log.d(TAG, "Characteristic not found for notification");
        } else if (throwable instanceof BleCannotSetCharacteristicNotificationException) {
            UserError.Log.e(TAG, "Problems setting notifications - disconnecting");
        } else if (throwable instanceof BleDisconnectedException) {
            UserError.Log.d(TAG, "Disconnected while enabling notifications");
        } else if (throwable instanceof TimeoutException) {
            UserError.Log.d(TAG, "Timeout");
        }
        resetFirmwareState(false);
    }));
}
Also used : AUTHORIZE_FAILED(com.eveningoutpost.dexdrip.watch.miband.MiBandService.MiBandState.AUTHORIZE_FAILED) AUTH_REQUEST_RANDOM_AUTH_NUMBER(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes.AUTH_REQUEST_RANDOM_AUTH_NUMBER) AuthMessages(com.eveningoutpost.dexdrip.watch.miband.message.AuthMessages) Arrays(java.util.Arrays) com.eveningoutpost.dexdrip.xdrip(com.eveningoutpost.dexdrip.xdrip) Date(java.util.Date) TimeoutException(java.util.concurrent.TimeoutException) PendingIntent(android.app.PendingIntent) CLOSED(com.eveningoutpost.dexdrip.Services.JamBaseBluetoothSequencer.BaseState.CLOSED) INIT(com.eveningoutpost.dexdrip.Services.JamBaseBluetoothSequencer.BaseState.INIT) Inevitable(com.eveningoutpost.dexdrip.UtilityModels.Inevitable) BleCannotSetCharacteristicNotificationException(com.polidea.rxandroidble2.exceptions.BleCannotSetCharacteristicNotificationException) PowerManager(android.os.PowerManager) HeartRate(com.eveningoutpost.dexdrip.Models.HeartRate) StatusItem(com.eveningoutpost.dexdrip.UtilityModels.StatusItem) BleCharacteristicNotFoundException(com.polidea.rxandroidble2.exceptions.BleCharacteristicNotFoundException) COMMAND_ACK_FIND_PHONE_IN_PROGRESS(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes.COMMAND_ACK_FIND_PHONE_IN_PROGRESS) AUTH_FAIL(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes.AUTH_FAIL) Schedulers(io.reactivex.schedulers.Schedulers) AUTH_MIBAND4_CODE_FAIL(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes.AUTH_MIBAND4_CODE_FAIL) AUTH_RESPONSE(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes.AUTH_RESPONSE) AUTH_SEND_KEY(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes.AUTH_SEND_KEY) ActiveBgAlert(com.eveningoutpost.dexdrip.Models.ActiveBgAlert) FeaturesControllMessage(com.eveningoutpost.dexdrip.watch.miband.message.FeaturesControllMessage) MIBAND_NOTIFY_TYPE_ALARM(com.eveningoutpost.dexdrip.watch.miband.Const.MIBAND_NOTIFY_TYPE_ALARM) CLOSE(com.eveningoutpost.dexdrip.Services.JamBaseBluetoothSequencer.BaseState.CLOSE) BgReading(com.eveningoutpost.dexdrip.Models.BgReading) PrefBindingFactory(com.eveningoutpost.dexdrip.watch.PrefBindingFactory) UUID(java.util.UUID) JoH.getResourceURI(com.eveningoutpost.dexdrip.Models.JoH.getResourceURI) UNKNOWN(com.eveningoutpost.dexdrip.watch.miband.MiBand.MiBandType.UNKNOWN) JoH(com.eveningoutpost.dexdrip.Models.JoH) List(java.util.List) BleDisconnectedException(com.polidea.rxandroidble2.exceptions.BleDisconnectedException) JoH.bytesToHex(com.eveningoutpost.dexdrip.Models.JoH.bytesToHex) MIBAND_NOTIFY_TYPE_CANCEL(com.eveningoutpost.dexdrip.watch.miband.Const.MIBAND_NOTIFY_TYPE_CANCEL) R(com.eveningoutpost.dexdrip.R) Subscription(com.eveningoutpost.dexdrip.utils.bt.Subscription) PREFERRED_MTU_SIZE(com.eveningoutpost.dexdrip.watch.miband.Const.PREFERRED_MTU_SIZE) AlertLevelMessage(com.eveningoutpost.dexdrip.watch.miband.message.AlertLevelMessage) JoH.msTill(com.eveningoutpost.dexdrip.Models.JoH.msTill) AUTH_SUCCESS(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes.AUTH_SUCCESS) Getter(lombok.Getter) BluetoothGattCharacteristic(android.bluetooth.BluetoothGattCharacteristic) WakeLockTrampoline(com.eveningoutpost.dexdrip.utils.framework.WakeLockTrampoline) Constants(com.eveningoutpost.dexdrip.UtilityModels.Constants) AUTH_SEND_ENCRYPTED_AUTH_NUMBER(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes.AUTH_SEND_ENCRYPTED_AUTH_NUMBER) Pair(android.util.Pair) FirmwareOperations(com.eveningoutpost.dexdrip.watch.miband.Firmware.FirmwareOperations) DisplayControllMessageMiband3_4(com.eveningoutpost.dexdrip.watch.miband.message.DisplayControllMessageMiband3_4) RxBleConnection(com.polidea.rxandroidble2.RxBleConnection) Intent(android.content.Intent) MediaPlayer(android.media.MediaPlayer) ArrayList(java.util.ArrayList) JoH.niceTimeScalar(com.eveningoutpost.dexdrip.Models.JoH.niceTimeScalar) SuppressLint(android.annotation.SuppressLint) Calendar(java.util.Calendar) DeviceEvent(com.eveningoutpost.dexdrip.watch.miband.message.DeviceEvent) DisplayControllMessageMiBand2(com.eveningoutpost.dexdrip.watch.miband.message.DisplayControllMessageMiBand2) DisplayControllMessage(com.eveningoutpost.dexdrip.watch.miband.message.DisplayControllMessage) COMMAND_DISABLE_CALL(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes.COMMAND_DISABLE_CALL) JamBaseBluetoothSequencer(com.eveningoutpost.dexdrip.Services.JamBaseBluetoothSequencer) AlertMessage(com.eveningoutpost.dexdrip.watch.miband.message.AlertMessage) MI_BAND4(com.eveningoutpost.dexdrip.watch.miband.MiBand.MiBandType.MI_BAND4) Sheduled(com.eveningoutpost.dexdrip.watch.miband.message.DisplayControllMessageMiband3_4.NightMode.Sheduled) RxBleDeviceServices(com.polidea.rxandroidble2.RxBleDeviceServices) MI_BAND2(com.eveningoutpost.dexdrip.watch.miband.MiBand.MiBandType.MI_BAND2) JoH.emptyString(com.eveningoutpost.dexdrip.Models.JoH.emptyString) SLEEP(com.eveningoutpost.dexdrip.Services.JamBaseBluetoothSequencer.BaseState.SLEEP) BluetoothGattService(android.bluetooth.BluetoothGattService) com.eveningoutpost.dexdrip.xdrip.gs(com.eveningoutpost.dexdrip.xdrip.gs) AUTH_MIBAND4_FAIL(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes.AUTH_MIBAND4_FAIL) WatchFaceGenerator(com.eveningoutpost.dexdrip.watch.miband.Firmware.WatchFaceGenerator) AlertPlayer(com.eveningoutpost.dexdrip.UtilityModels.AlertPlayer) PoorMansConcurrentLinkedDeque(com.eveningoutpost.dexdrip.utils.framework.PoorMansConcurrentLinkedDeque) TimeUnit(java.util.concurrent.TimeUnit) MIBAND_NOTIFY_TYPE_MESSAGE(com.eveningoutpost.dexdrip.watch.miband.Const.MIBAND_NOTIFY_TYPE_MESSAGE) OperationCodes(com.eveningoutpost.dexdrip.watch.miband.message.OperationCodes) UserError(com.eveningoutpost.dexdrip.Models.UserError) MIBAND_NOTIFY_TYPE_CALL(com.eveningoutpost.dexdrip.watch.miband.Const.MIBAND_NOTIFY_TYPE_CALL) FirmwareOperations(com.eveningoutpost.dexdrip.watch.miband.Firmware.FirmwareOperations) BleCannotSetCharacteristicNotificationException(com.polidea.rxandroidble2.exceptions.BleCannotSetCharacteristicNotificationException) BleCharacteristicNotFoundException(com.polidea.rxandroidble2.exceptions.BleCharacteristicNotFoundException) BleDisconnectedException(com.polidea.rxandroidble2.exceptions.BleDisconnectedException) RxBleConnection(com.polidea.rxandroidble2.RxBleConnection) Subscription(com.eveningoutpost.dexdrip.utils.bt.Subscription) TimeoutException(java.util.concurrent.TimeoutException) BleCannotSetCharacteristicNotificationException(com.polidea.rxandroidble2.exceptions.BleCannotSetCharacteristicNotificationException) BleCharacteristicNotFoundException(com.polidea.rxandroidble2.exceptions.BleCharacteristicNotFoundException) BleDisconnectedException(com.polidea.rxandroidble2.exceptions.BleDisconnectedException) WatchFaceGenerator(com.eveningoutpost.dexdrip.watch.miband.Firmware.WatchFaceGenerator) TimeoutException(java.util.concurrent.TimeoutException) SuppressLint(android.annotation.SuppressLint)

Example 10 with BleDisconnectedException

use of com.polidea.rxandroidble2.exceptions.BleDisconnectedException in project xDrip-plus by jamorham.

the class InPenService method getRecords.

private void getRecords(final int firstIndex, final int lastIndex) {
    final int numberOfRecords = lastIndex - firstIndex;
    if (numberOfRecords > 30) {
        I.connection.writeCharacteristic(KEEPALIVE, new KeepAliveTx().getBytes()).subscribe(value -> {
            UserError.Log.d(TAG, "Wrote keep alive for " + numberOfRecords);
        }, throwable -> {
            UserError.Log.d(TAG, "Got exception in keep alive" + throwable);
        });
    }
    final RecordTx packet = new RecordTx(firstIndex, lastIndex);
    UserError.Log.d(TAG, "getRecords called, loading: " + firstIndex + " to " + lastIndex);
    I.connection.setupIndication(RECORD_INDICATE).doOnNext(notificationObservable -> {
        I.connection.writeCharacteristic(RECORD_START, packet.startBytes()).subscribe(valueS -> {
            UserError.Log.d(TAG, "Wrote record start: " + bytesToHex(valueS));
            I.connection.writeCharacteristic(RECORD_END, packet.endBytes()).subscribe(valueE -> {
                UserError.Log.d(TAG, "Wrote record end: " + bytesToHex(valueE));
                I.connection.writeCharacteristic(RECORD_REQUEST, packet.triggerBytes()).subscribe(characteristicValue -> {
                    if (D)
                        UserError.Log.d(TAG, "Wrote record request request: " + bytesToHex(characteristicValue));
                }, throwable -> {
                    UserError.Log.e(TAG, "Failed to write record request: " + throwable);
                    if (throwable instanceof BleGattCharacteristicException) {
                        final int status = ((BleGattCharacteristicException) throwable).getStatus();
                        UserError.Log.e(TAG, "Got status message: " + Helper.getStatusName(status));
                    }
                });
            }, throwable -> {
                UserError.Log.d(TAG, "Throwable in Record End write: " + throwable);
            });
        }, throwable -> {
            UserError.Log.d(TAG, "Throwable in Record Start write: " + throwable);
        // throws BleGattCharacteristicException status = 128 for "no resources" eg nothing matches
        });
    }).flatMap(notificationObservable -> notificationObservable).timeout(120, TimeUnit.SECONDS).observeOn(Schedulers.newThread()).subscribe(bytes -> {
        records.add(bytes);
        UserError.Log.d(TAG, "INDICATE INDICATE: " + HexDump.dumpHexString(bytes));
    }, throwable -> {
        if (!(throwable instanceof OperationSuccess)) {
            if (throwable instanceof BleDisconnectedException) {
                UserError.Log.d(TAG, "Disconnected when waiting to receive indication: " + throwable);
            } else {
                UserError.Log.e(TAG, "Error receiving indication: " + throwable);
            }
            Inevitable.task("check-records-queue", 100, this::processRecordsQueue);
        }
    });
}
Also used : KeepAliveTx(com.eveningoutpost.dexdrip.insulin.inpen.messages.KeepAliveTx) Arrays(java.util.Arrays) TypeToken(com.google.gson.reflect.TypeToken) AdvertRx(com.eveningoutpost.dexdrip.insulin.inpen.messages.AdvertRx) ProcessPenData(com.eveningoutpost.dexdrip.insulin.shared.ProcessPenData) GsonBuilder(com.google.gson.GsonBuilder) Inevitable(com.eveningoutpost.dexdrip.UtilityModels.Inevitable) Pref(com.eveningoutpost.dexdrip.UtilityModels.Pref) HexDump.dumpHexString(com.eveningoutpost.dexdrip.ImportedLibraries.usbserial.util.HexDump.dumpHexString) Map(java.util.Map) BleGattCharacteristicException(com.polidea.rxandroidble2.exceptions.BleGattCharacteristicException) TargetApi(android.annotation.TargetApi) INFO_CHARACTERISTICS(com.eveningoutpost.dexdrip.insulin.inpen.Constants.INFO_CHARACTERISTICS) RECORD_INDEX(com.eveningoutpost.dexdrip.insulin.inpen.Constants.RECORD_INDEX) DEFAULT_BOND_UNITS(com.eveningoutpost.dexdrip.insulin.inpen.InPen.DEFAULT_BOND_UNITS) RECORD_REQUEST(com.eveningoutpost.dexdrip.insulin.inpen.Constants.RECORD_REQUEST) JoH(com.eveningoutpost.dexdrip.Models.JoH) JoH.bytesToHex(com.eveningoutpost.dexdrip.Models.JoH.bytesToHex) BOND_NONE(android.bluetooth.BluetoothDevice.BOND_NONE) STORE_INPEN_ADVERT(com.eveningoutpost.dexdrip.insulin.inpen.InPen.STORE_INPEN_ADVERT) RecordRx(com.eveningoutpost.dexdrip.insulin.inpen.messages.RecordRx) BATTERY(com.eveningoutpost.dexdrip.insulin.inpen.Constants.BATTERY) PenData(com.eveningoutpost.dexdrip.Models.PenData) STORE_INPEN_BATTERY(com.eveningoutpost.dexdrip.insulin.inpen.InPen.STORE_INPEN_BATTERY) BluetoothGattCharacteristic(android.bluetooth.BluetoothGattCharacteristic) WakeLockTrampoline(com.eveningoutpost.dexdrip.utils.framework.WakeLockTrampoline) BatteryRx(com.eveningoutpost.dexdrip.insulin.inpen.messages.BatteryRx) GOOD(com.eveningoutpost.dexdrip.UtilityModels.StatusItem.Highlight.GOOD) BONDCONTROL(com.eveningoutpost.dexdrip.insulin.inpen.Constants.BONDCONTROL) HexDump(com.eveningoutpost.dexdrip.ImportedLibraries.usbserial.util.HexDump) ArrayList(java.util.ArrayList) BOND_AUTHORITY(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.BOND_AUTHORITY) Helper(com.eveningoutpost.dexdrip.utils.bt.Helper) Observable(io.reactivex.Observable) JamBaseBluetoothSequencer(com.eveningoutpost.dexdrip.Services.JamBaseBluetoothSequencer) RxBleDeviceServices(com.polidea.rxandroidble2.RxBleDeviceServices) BONDAGE(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.BONDAGE) BondTx(com.eveningoutpost.dexdrip.insulin.inpen.messages.BondTx) Converters(com.eveningoutpost.dexdrip.utils.math.Converters) JoH.ratelimit(com.eveningoutpost.dexdrip.Models.JoH.ratelimit) JoH.quietratelimit(com.eveningoutpost.dexdrip.Models.JoH.quietratelimit) RecordTx(com.eveningoutpost.dexdrip.insulin.inpen.messages.RecordTx) RECORD_END(com.eveningoutpost.dexdrip.insulin.inpen.Constants.RECORD_END) GET_AUTH_STATE(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.GET_AUTH_STATE) UserError(com.eveningoutpost.dexdrip.Models.UserError) PersistentStore(com.eveningoutpost.dexdrip.UtilityModels.PersistentStore) HEXDUMP_INFO_CHARACTERISTICS(com.eveningoutpost.dexdrip.insulin.inpen.Constants.HEXDUMP_INFO_CHARACTERISTICS) InPenEntry.isStarted(com.eveningoutpost.dexdrip.insulin.inpen.InPenEntry.isStarted) PendingIntent(android.app.PendingIntent) INIT(com.eveningoutpost.dexdrip.Services.JamBaseBluetoothSequencer.BaseState.INIT) PEN_ATTACH_TIME(com.eveningoutpost.dexdrip.insulin.inpen.Constants.PEN_ATTACH_TIME) GET_BATTERY(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.GET_BATTERY) PowerManager(android.os.PowerManager) StatusItem(com.eveningoutpost.dexdrip.UtilityModels.StatusItem) KEEP_ALIVE(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.KEEP_ALIVE) Gson(com.google.gson.Gson) Schedulers(io.reactivex.schedulers.Schedulers) GET_INDEX(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.GET_INDEX) BAD(com.eveningoutpost.dexdrip.UtilityModels.StatusItem.Highlight.BAD) GET_RECORDS(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.GET_RECORDS) INPEN_SERVICE_FAILOVER_ID(com.eveningoutpost.dexdrip.UtilityModels.Constants.INPEN_SERVICE_FAILOVER_ID) CLOSE(com.eveningoutpost.dexdrip.Services.JamBaseBluetoothSequencer.BaseState.CLOSE) NORMAL(com.eveningoutpost.dexdrip.UtilityModels.StatusItem.Highlight.NORMAL) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) KEEPALIVE(com.eveningoutpost.dexdrip.insulin.inpen.Constants.KEEPALIVE) Helper.getCharactersticName(com.eveningoutpost.dexdrip.utils.bt.Helper.getCharactersticName) UUID(java.util.UUID) GET_TIME(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.GET_TIME) List(java.util.List) Disposable(io.reactivex.disposables.Disposable) BleDisconnectedException(com.polidea.rxandroidble2.exceptions.BleDisconnectedException) R(com.eveningoutpost.dexdrip.R) REMAINING_INDEX(com.eveningoutpost.dexdrip.insulin.inpen.Constants.REMAINING_INDEX) Queue(java.util.Queue) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) BluetoothDevice(android.bluetooth.BluetoothDevice) GET_AUTH_STATE2(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.GET_AUTH_STATE2) RECORD_INDICATE(com.eveningoutpost.dexdrip.insulin.inpen.Constants.RECORD_INDICATE) Intent(android.content.Intent) HashMap(java.util.HashMap) GET_A_TIME(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.GET_A_TIME) JoH.dateTimeText(com.eveningoutpost.dexdrip.Models.JoH.dateTimeText) JoH.hourMinuteString(com.eveningoutpost.dexdrip.Models.JoH.hourMinuteString) Scheduler(io.reactivex.Scheduler) BleGattException(com.polidea.rxandroidble2.exceptions.BleGattException) ID_INPEN(com.eveningoutpost.dexdrip.insulin.inpen.InPenEntry.ID_INPEN) STORE_INPEN_INFOS(com.eveningoutpost.dexdrip.insulin.inpen.InPen.STORE_INPEN_INFOS) Build(android.os.Build) TimeRx(com.eveningoutpost.dexdrip.insulin.inpen.messages.TimeRx) SlidingWindowConstraint(com.eveningoutpost.dexdrip.utils.time.SlidingWindowConstraint) AUTHENTICATION(com.eveningoutpost.dexdrip.insulin.inpen.Constants.AUTHENTICATION) PRINTABLE_INFO_CHARACTERISTICS(com.eveningoutpost.dexdrip.insulin.inpen.Constants.PRINTABLE_INFO_CHARACTERISTICS) JoH.emptyString(com.eveningoutpost.dexdrip.Models.JoH.emptyString) BluetoothGattService(android.bluetooth.BluetoothGattService) PEN_TIME(com.eveningoutpost.dexdrip.insulin.inpen.Constants.PEN_TIME) RECORD_START(com.eveningoutpost.dexdrip.insulin.inpen.Constants.RECORD_START) GET_IDENTITY(com.eveningoutpost.dexdrip.insulin.inpen.InPenService.InPenState.GET_IDENTITY) JoH.msSince(com.eveningoutpost.dexdrip.Models.JoH.msSince) TimeUnit(java.util.concurrent.TimeUnit) BOND_BONDED(android.bluetooth.BluetoothDevice.BOND_BONDED) KeepAliveTx(com.eveningoutpost.dexdrip.insulin.inpen.messages.KeepAliveTx) SECOND_IN_MS(com.eveningoutpost.dexdrip.UtilityModels.Constants.SECOND_IN_MS) MINUTE_IN_MS(com.eveningoutpost.dexdrip.UtilityModels.Constants.MINUTE_IN_MS) BleGattCharacteristicException(com.polidea.rxandroidble2.exceptions.BleGattCharacteristicException) RecordTx(com.eveningoutpost.dexdrip.insulin.inpen.messages.RecordTx) BleDisconnectedException(com.polidea.rxandroidble2.exceptions.BleDisconnectedException) SlidingWindowConstraint(com.eveningoutpost.dexdrip.utils.time.SlidingWindowConstraint)

Aggregations

BleDisconnectedException (com.polidea.rxandroidble2.exceptions.BleDisconnectedException)12 SuppressLint (android.annotation.SuppressLint)10 PowerManager (android.os.PowerManager)10 JoH (com.eveningoutpost.dexdrip.Models.JoH)10 UserError (com.eveningoutpost.dexdrip.Models.UserError)10 R (com.eveningoutpost.dexdrip.R)10 Inevitable (com.eveningoutpost.dexdrip.UtilityModels.Inevitable)10 Schedulers (io.reactivex.schedulers.Schedulers)10 ArrayList (java.util.ArrayList)10 Arrays (java.util.Arrays)10 List (java.util.List)10 TimeUnit (java.util.concurrent.TimeUnit)10 BgReading (com.eveningoutpost.dexdrip.Models.BgReading)8 Constants (com.eveningoutpost.dexdrip.UtilityModels.Constants)8 com.eveningoutpost.dexdrip.xdrip (com.eveningoutpost.dexdrip.xdrip)8 BleCannotSetCharacteristicNotificationException (com.polidea.rxandroidble2.exceptions.BleCannotSetCharacteristicNotificationException)8 BleGattCharacteristicException (com.polidea.rxandroidble2.exceptions.BleGattCharacteristicException)8 BluetoothGattCharacteristic (android.bluetooth.BluetoothGattCharacteristic)7 BluetoothGattService (android.bluetooth.BluetoothGattService)7 Intent (android.content.Intent)7