mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-02-04 21:13:54 +01:00
Mi2: attempt to enable text notifications #560
This commit is contained in:
parent
c56b655b48
commit
1c06aaace1
@ -2,6 +2,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.miband2;
|
|||||||
|
|
||||||
import android.bluetooth.BluetoothGattCharacteristic;
|
import android.bluetooth.BluetoothGattCharacteristic;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBand2Service;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.VibrationProfile;
|
import nodomain.freeyourgadget.gadgetbridge.devices.miband.VibrationProfile;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport;
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.BtLEAction;
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.BtLEAction;
|
||||||
@ -19,27 +20,34 @@ public class Mi2NotificationStrategy extends V2NotificationStrategy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void sendCustomNotification(VibrationProfile vibrationProfile, SimpleNotification simpleNotification, BtLEAction extraAction, TransactionBuilder builder) {
|
protected void sendCustomNotification(VibrationProfile vibrationProfile, SimpleNotification simpleNotification, BtLEAction extraAction, TransactionBuilder builder) {
|
||||||
|
// for testing
|
||||||
|
|
||||||
//use the new alert characteristic
|
//use the new alert characteristic
|
||||||
BluetoothGattCharacteristic alert = getSupport().getCharacteristic(GattCharacteristic.UUID_CHARACTERISTIC_ALERT_LEVEL);
|
// BluetoothGattCharacteristic alert = getSupport().getCharacteristic(GattCharacteristic.UUID_CHARACTERISTIC_ALERT_LEVEL);
|
||||||
for (short i = 0; i < vibrationProfile.getRepeat(); i++) {
|
// for (short i = 0; i < vibrationProfile.getRepeat(); i++) {
|
||||||
int[] onOffSequence = vibrationProfile.getOnOffSequence();
|
// int[] onOffSequence = vibrationProfile.getOnOffSequence();
|
||||||
for (int j = 0; j < onOffSequence.length; j++) {
|
// for (int j = 0; j < onOffSequence.length; j++) {
|
||||||
int on = onOffSequence[j];
|
// int on = onOffSequence[j];
|
||||||
on = Math.min(500, on); // longer than 500ms is not possible
|
// on = Math.min(500, on); // longer than 500ms is not possible
|
||||||
builder.write(alert, new byte[]{(byte) vibrationProfile.getAlertLevel()});
|
// builder.write(alert, new byte[]{(byte) vibrationProfile.getAlertLevel()});
|
||||||
builder.wait(on);
|
// builder.wait(on);
|
||||||
builder.write(alert, new byte[]{GattCharacteristic.NO_ALERT});
|
// builder.write(alert, new byte[]{GattCharacteristic.NO_ALERT});
|
||||||
|
//
|
||||||
|
// if (++j < onOffSequence.length) {
|
||||||
|
// int off = Math.max(onOffSequence[j], 25); // wait at least 25ms
|
||||||
|
// builder.wait(off);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (extraAction != null) {
|
||||||
|
// builder.add(extraAction);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
if (++j < onOffSequence.length) {
|
BluetoothGattCharacteristic config = getSupport().getCharacteristic(MiBand2Service.UUID_CHARACTERISTIC_3_CONFIGURATION);
|
||||||
int off = Math.max(onOffSequence[j], 25); // wait at least 25ms
|
builder.write(config, new byte[] {MiBand2Service.ENDPOINT_DISPLAY, 0x10, 0x00, 0x01, 0x01});
|
||||||
builder.wait(off);
|
builder.wait(500);
|
||||||
}
|
// end for testing
|
||||||
|
|
||||||
if (extraAction != null) {
|
|
||||||
builder.add(extraAction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sendAlert(simpleNotification, builder);
|
sendAlert(simpleNotification, builder);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user