use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class HPlusSupport method showIncomingCall.
private void showIncomingCall(String name, String rawNumber) {
try {
StringBuilder number = new StringBuilder();
//Clean up number as the device only accepts digits
for (char c : rawNumber.toCharArray()) {
if (Character.isDigit(c)) {
number.append(c);
}
}
TransactionBuilder builder = performInitialized("incomingCall");
//Enable call notifications
builder.write(ctrlCharacteristic, new byte[] { HPlusConstants.CMD_ACTION_INCOMING_CALL, 1 });
//Show Call Icon
builder.write(ctrlCharacteristic, new byte[] { HPlusConstants.CMD_SET_INCOMING_CALL, HPlusConstants.ARG_INCOMING_CALL });
byte[] msg = new byte[13];
for (int i = 0; i < msg.length; i++) msg[i] = ' ';
byte[] nameBytes = encodeStringToDevice(name);
for (int i = 0; i < nameBytes.length && i < (msg.length - 1); i++) msg[i + 1] = nameBytes[i];
msg[0] = HPlusConstants.CMD_ACTION_DISPLAY_TEXT_NAME;
builder.write(ctrlCharacteristic, msg);
msg[0] = HPlusConstants.CMD_ACTION_DISPLAY_TEXT_NAME_CN;
builder.write(ctrlCharacteristic, msg);
builder.wait(200);
msg = msg.clone();
//Show call number
for (int i = 0; i < msg.length; i++) msg[i] = ' ';
for (int i = 0; i < number.length() && i < (msg.length - 1); i++) msg[i + 1] = (byte) number.charAt(i);
msg[0] = HPlusConstants.CMD_SET_INCOMING_CALL_NUMBER;
builder.write(ctrlCharacteristic, msg);
builder.queue(getQueue());
} catch (IOException e) {
GB.toast(getContext(), "Error showing incoming call: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
}
}
use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class HPlusSupport method onReboot.
@Override
public void onReboot() {
getQueue().clear();
TransactionBuilder builder = new TransactionBuilder("Shutdown");
builder.write(ctrlCharacteristic, new byte[] { HPlusConstants.CMD_SHUTDOWN, HPlusConstants.ARG_SHUTDOWN_EN });
builder.queue(getQueue());
}
use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class HPlusSupport method onSetAlarms.
@Override
public void onSetAlarms(ArrayList<? extends Alarm> alarms) {
TransactionBuilder builder = new TransactionBuilder("alarm");
for (Alarm alarm : alarms) {
if (!alarm.isEnabled())
continue;
if (//Not available
alarm.isSmartWakeup())
continue;
Calendar t = alarm.getAlarmCal();
setAlarm(builder, t);
builder.queue(getQueue());
GB.toast(getContext(), getContext().getString(R.string.user_feedback_miband_set_alarms_ok), Toast.LENGTH_SHORT, GB.INFO);
//Only first alarm
return;
}
setAlarm(builder, null);
builder.queue(getQueue());
GB.toast(getContext(), getContext().getString(R.string.user_feedback_all_alarms_disabled), Toast.LENGTH_SHORT, GB.INFO);
}
use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class HPlusSupport method onEnableRealtimeHeartRateMeasurement.
@Override
public void onEnableRealtimeHeartRateMeasurement(boolean enable) {
getQueue().clear();
TransactionBuilder builder = new TransactionBuilder("realTimeHeartMeasurement");
byte state;
if (enable)
state = HPlusConstants.ARG_HEARTRATE_ALLDAY_ON;
else
state = HPlusConstants.ARG_HEARTRATE_ALLDAY_OFF;
builder.write(ctrlCharacteristic, new byte[] { HPlusConstants.CMD_SET_ALLDAY_HRM, state });
builder.queue(getQueue());
}
use of nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder in project Gadgetbridge by Freeyourgadget.
the class HPlusSupport method onHeartRateTest.
@Override
public void onHeartRateTest() {
getQueue().clear();
TransactionBuilder builder = new TransactionBuilder("HeartRateTest");
//Set Real Time... ?
builder.write(ctrlCharacteristic, new byte[] { HPlusConstants.CMD_SET_HEARTRATE_STATE, HPlusConstants.ARG_HEARTRATE_MEASURE_ON });
builder.queue(getQueue());
}
Aggregations