Search in sources :

Example 1 with AlertMessage

use of com.eveningoutpost.dexdrip.watch.miband.message.AlertMessage in project xDrip by NightscoutFoundation.

the class MiBandService method queueMessage.

private void queueMessage() {
    String message = queueItem.message;
    if (d)
        UserError.Log.d(TAG, "Queuing message alert: " + message);
    if (isWaitingSnoozeResponce) {
        // disable call
        vibrateAlert(AlertLevelMessage.AlertLevelType.NoAlert);
        isWaitingSnoozeResponce = false;
    }
    AlertMessage alertMessage = new AlertMessage();
    switch(queueItem.message_type != null ? queueItem.message_type : "null") {
        case MIBAND_NOTIFY_TYPE_CALL:
            new QueueMe().setBytes(alertMessage.getAlertMessageOld(message, AlertMessage.AlertCategory.Call)).setDescription("Send call alert: " + message).setQueueWriteCharacterstic(alertMessage.getCharacteristicUUID()).setRunnable(() -> isWaitingCallResponce = true).expireInSeconds(QUEUE_EXPIRED_TIME).setDelayMs(QUEUE_DELAY).queue();
            if (d)
                UserError.Log.d(TAG, "Queued call alert: " + message);
            break;
        case MIBAND_NOTIFY_TYPE_CANCEL:
            if (isWaitingCallResponce) {
                // disable call
                vibrateAlert(AlertLevelMessage.AlertLevelType.NoAlert);
                isWaitingCallResponce = false;
                if (d)
                    UserError.Log.d(TAG, "Call disabled");
            }
            break;
        case MIBAND_NOTIFY_TYPE_ALARM:
            new QueueMe().setBytes(alertMessage.getAlertMessageOld(message, AlertMessage.AlertCategory.Call)).setDescription("Sent glucose alert: " + message).setQueueWriteCharacterstic(alertMessage.getCharacteristicUUID()).expireInSeconds(QUEUE_EXPIRED_TIME).setRunnable(() -> isWaitingSnoozeResponce = true).setDelayMs(QUEUE_DELAY).queue();
            bgServiceIntent = WakeLockTrampoline.getPendingIntent(this.getClass(), Constants.MIBAND_SERVICE_BG_RETRY_ID, "glucose_after");
            JoH.wakeUpIntent(xdrip.getAppContext(), CALL_ALERT_DELAY, bgServiceIntent);
            break;
        case MIBAND_NOTIFY_TYPE_MESSAGE:
            if (MiBand.getMibandType() == MI_BAND2) {
                new QueueMe().setBytes(alertMessage.getAlertMessageOld(message, AlertMessage.AlertCategory.SMS_MMS)).setDescription("Sent message: " + message).setQueueWriteCharacterstic(alertMessage.getCharacteristicUUID()).expireInSeconds(QUEUE_EXPIRED_TIME).setDelayMs(QUEUE_DELAY).queue();
            } else {
                new QueueMe().setBytes(alertMessage.getAlertMessage(message, AlertMessage.AlertCategory.CustomHuami, AlertMessage.CustomIcon.RED_WHITE_FIRE_8, queueItem.title)).setDescription("Sent message: " + message).setQueueWriteCharacterstic(alertMessage.getCharacteristicUUID()).expireInSeconds(QUEUE_EXPIRED_TIME).setDelayMs(QUEUE_DELAY).queue();
            }
            break;
        default:
            // glucose
            break;
    }
    // this parent method might get called multiple times
    Inevitable.task("miband-s-queue", 200, () -> changeState(mState.next()));
}
Also used : JoH.emptyString(com.eveningoutpost.dexdrip.Models.JoH.emptyString) AlertMessage(com.eveningoutpost.dexdrip.watch.miband.message.AlertMessage)

Example 2 with AlertMessage

use of com.eveningoutpost.dexdrip.watch.miband.message.AlertMessage in project xDrip by NightscoutFoundation.

the class MiBandService method sendBG.

private Boolean sendBG() {
    BgReading last = BgReading.last();
    AlertMessage message = new AlertMessage();
    if (last == null || last.isStale()) {
        return false;
    } else {
        String messageText = "BG: " + last.displayValue(null) + " " + last.displaySlopeArrow();
        UserError.Log.uel(TAG, "Send alert msg: " + messageText);
        if (MiBand.getMibandType() == MI_BAND2) {
            new QueueMe().setBytes(message.getAlertMessageOld(messageText.toUpperCase(), AlertMessage.AlertCategory.SMS_MMS)).setDescription("Send alert msg: " + messageText).setQueueWriteCharacterstic(message.getCharacteristicUUID()).expireInSeconds(QUEUE_EXPIRED_TIME).setDelayMs(QUEUE_DELAY).queue();
        } else {
            new QueueMe().setBytes(message.getAlertMessage(messageText.toUpperCase(), AlertMessage.AlertCategory.CustomHuami, AlertMessage.CustomIcon.APP_11, messageText.toUpperCase())).setDescription("Send alert msg: " + messageText).setQueueWriteCharacterstic(message.getCharacteristicUUID()).expireInSeconds(QUEUE_EXPIRED_TIME).setDelayMs(QUEUE_DELAY).queue();
        }
    }
    return true;
}
Also used : BgReading(com.eveningoutpost.dexdrip.Models.BgReading) JoH.emptyString(com.eveningoutpost.dexdrip.Models.JoH.emptyString) AlertMessage(com.eveningoutpost.dexdrip.watch.miband.message.AlertMessage)

Example 3 with AlertMessage

use of com.eveningoutpost.dexdrip.watch.miband.message.AlertMessage in project xDrip-plus by jamorham.

the class MiBandService method queueMessage.

private void queueMessage() {
    String message = queueItem.message;
    if (d)
        UserError.Log.d(TAG, "Queuing message alert: " + message);
    if (isWaitingSnoozeResponce) {
        // disable call
        vibrateAlert(AlertLevelMessage.AlertLevelType.NoAlert);
        isWaitingSnoozeResponce = false;
    }
    AlertMessage alertMessage = new AlertMessage();
    switch(queueItem.message_type != null ? queueItem.message_type : "null") {
        case MIBAND_NOTIFY_TYPE_CALL:
            new QueueMe().setBytes(alertMessage.getAlertMessageOld(message, AlertMessage.AlertCategory.Call)).setDescription("Send call alert: " + message).setQueueWriteCharacterstic(alertMessage.getCharacteristicUUID()).setRunnable(() -> isWaitingCallResponce = true).expireInSeconds(QUEUE_EXPIRED_TIME).setDelayMs(QUEUE_DELAY).queue();
            if (d)
                UserError.Log.d(TAG, "Queued call alert: " + message);
            break;
        case MIBAND_NOTIFY_TYPE_CANCEL:
            if (isWaitingCallResponce) {
                // disable call
                vibrateAlert(AlertLevelMessage.AlertLevelType.NoAlert);
                isWaitingCallResponce = false;
                if (d)
                    UserError.Log.d(TAG, "Call disabled");
            }
            break;
        case MIBAND_NOTIFY_TYPE_ALARM:
            new QueueMe().setBytes(alertMessage.getAlertMessageOld(message, AlertMessage.AlertCategory.Call)).setDescription("Sent glucose alert: " + message).setQueueWriteCharacterstic(alertMessage.getCharacteristicUUID()).expireInSeconds(QUEUE_EXPIRED_TIME).setRunnable(() -> isWaitingSnoozeResponce = true).setDelayMs(QUEUE_DELAY).queue();
            bgServiceIntent = WakeLockTrampoline.getPendingIntent(this.getClass(), Constants.MIBAND_SERVICE_BG_RETRY_ID, "glucose_after");
            JoH.wakeUpIntent(xdrip.getAppContext(), CALL_ALERT_DELAY, bgServiceIntent);
            break;
        case MIBAND_NOTIFY_TYPE_MESSAGE:
            if (MiBand.getMibandType() == MI_BAND2) {
                new QueueMe().setBytes(alertMessage.getAlertMessageOld(message, AlertMessage.AlertCategory.SMS_MMS)).setDescription("Sent message: " + message).setQueueWriteCharacterstic(alertMessage.getCharacteristicUUID()).expireInSeconds(QUEUE_EXPIRED_TIME).setDelayMs(QUEUE_DELAY).queue();
            } else {
                new QueueMe().setBytes(alertMessage.getAlertMessage(message, AlertMessage.AlertCategory.CustomHuami, AlertMessage.CustomIcon.RED_WHITE_FIRE_8, queueItem.title)).setDescription("Sent message: " + message).setQueueWriteCharacterstic(alertMessage.getCharacteristicUUID()).expireInSeconds(QUEUE_EXPIRED_TIME).setDelayMs(QUEUE_DELAY).queue();
            }
            break;
        default:
            // glucose
            break;
    }
    // this parent method might get called multiple times
    Inevitable.task("miband-s-queue", 200, () -> changeState(mState.next()));
}
Also used : JoH.emptyString(com.eveningoutpost.dexdrip.Models.JoH.emptyString) AlertMessage(com.eveningoutpost.dexdrip.watch.miband.message.AlertMessage)

Example 4 with AlertMessage

use of com.eveningoutpost.dexdrip.watch.miband.message.AlertMessage in project xDrip-plus by jamorham.

the class MiBandService method sendBG.

private Boolean sendBG() {
    BgReading last = BgReading.last();
    AlertMessage message = new AlertMessage();
    if (last == null || last.isStale()) {
        return false;
    } else {
        String messageText = "BG: " + last.displayValue(null) + " " + last.displaySlopeArrow();
        UserError.Log.uel(TAG, "Send alert msg: " + messageText);
        if (MiBand.getMibandType() == MI_BAND2) {
            new QueueMe().setBytes(message.getAlertMessageOld(messageText.toUpperCase(), AlertMessage.AlertCategory.SMS_MMS)).setDescription("Send alert msg: " + messageText).setQueueWriteCharacterstic(message.getCharacteristicUUID()).expireInSeconds(QUEUE_EXPIRED_TIME).setDelayMs(QUEUE_DELAY).queue();
        } else {
            new QueueMe().setBytes(message.getAlertMessage(messageText.toUpperCase(), AlertMessage.AlertCategory.CustomHuami, AlertMessage.CustomIcon.APP_11, messageText.toUpperCase())).setDescription("Send alert msg: " + messageText).setQueueWriteCharacterstic(message.getCharacteristicUUID()).expireInSeconds(QUEUE_EXPIRED_TIME).setDelayMs(QUEUE_DELAY).queue();
        }
    }
    return true;
}
Also used : BgReading(com.eveningoutpost.dexdrip.Models.BgReading) JoH.emptyString(com.eveningoutpost.dexdrip.Models.JoH.emptyString) AlertMessage(com.eveningoutpost.dexdrip.watch.miband.message.AlertMessage)

Aggregations

JoH.emptyString (com.eveningoutpost.dexdrip.Models.JoH.emptyString)4 AlertMessage (com.eveningoutpost.dexdrip.watch.miband.message.AlertMessage)4 BgReading (com.eveningoutpost.dexdrip.Models.BgReading)2