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()));
}
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;
}
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()));
}
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;
}
Aggregations