use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class ITagSupport method onSetConstantVibration.
@Override
public void onSetConstantVibration(int intensity) {
getQueue().clear();
BluetoothGattCharacteristic characteristic = getCharacteristic(ITagConstants.UUID_LINK_LOSS_ALERT_LEVEL);
TransactionBuilder builder = new TransactionBuilder("beeping");
builder.write(characteristic, new byte[] { (byte) intensity });
builder.queue(getQueue());
}
use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class JYouSupport method showNotification.
private void showNotification(byte icon, String title, String message) {
try {
TransactionBuilder builder = performInitialized("ShowNotification");
byte[] titleBytes = stringToUTF8Bytes(title, 16);
byte[] messageBytes = stringToUTF8Bytes(message, 80);
for (int i = 1; i <= 7; i++) {
byte[] currentPacket = new byte[20];
currentPacket[0] = JYouConstants.CMD_ACTION_SHOW_NOTIFICATION;
currentPacket[1] = 7;
currentPacket[2] = (byte) i;
switch(i) {
case 1:
currentPacket[4] = icon;
break;
case 2:
if (titleBytes != null) {
System.arraycopy(titleBytes, 0, currentPacket, 3, 6);
System.arraycopy(titleBytes, 6, currentPacket, 10, 10);
}
break;
default:
if (messageBytes != null) {
System.arraycopy(messageBytes, 16 * (i - 3), currentPacket, 3, 6);
System.arraycopy(messageBytes, 6 + 16 * (i - 3), currentPacket, 10, 10);
}
break;
}
builder.write(ctrlCharacteristic, currentPacket);
}
performConnected(builder.getTransaction());
} catch (IOException e) {
logger.warn(e.getMessage());
}
}
use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class JYouSupport method onSetAlarms.
@Override
public void onSetAlarms(ArrayList<? extends Alarm> alarms) {
try {
TransactionBuilder builder = performInitialized("SetAlarms");
for (int i = 0; i < alarms.size(); i++) {
byte cmd;
switch(i) {
case 0:
cmd = JYouConstants.CMD_SET_ALARM_1;
break;
case 1:
cmd = JYouConstants.CMD_SET_ALARM_2;
break;
case 2:
cmd = JYouConstants.CMD_SET_ALARM_3;
break;
default:
return;
}
Calendar cal = AlarmUtils.toCalendar(alarms.get(i));
builder.write(ctrlCharacteristic, commandWithChecksum(cmd, alarms.get(i).getEnabled() ? cal.get(Calendar.HOUR_OF_DAY) : -1, alarms.get(i).getEnabled() ? cal.get(Calendar.MINUTE) : -1));
}
performConnected(builder.getTransaction());
GB.toast(getContext(), "Alarm settings applied - do note that the current device does not support day specification", Toast.LENGTH_LONG, GB.INFO);
} catch (IOException e) {
logger.warn(e.getMessage());
}
}
use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class JYouSupport method onEnableRealtimeHeartRateMeasurement.
@Override
public void onEnableRealtimeHeartRateMeasurement(boolean enable) {
try {
TransactionBuilder builder = performInitialized("RealTimeHeartMeasurement");
builder.write(ctrlCharacteristic, commandWithChecksum(JYouConstants.CMD_SET_HEARTRATE_AUTO, 0, enable ? 1 : 0));
builder.queue(getQueue());
} catch (Exception e) {
logger.warn(e.getMessage());
}
}
use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class JYouSupport method onSetTime.
@Override
public void onSetTime() {
try {
TransactionBuilder builder = performInitialized("SetTime");
syncDateAndTime(builder);
performConnected(builder.getTransaction());
} catch (IOException e) {
logger.warn(e.getMessage());
}
}
Aggregations