mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-25 16:15:55 +01:00
added find my device support
This commit is contained in:
parent
f9a4c1ad35
commit
c57d5d3659
@ -115,7 +115,7 @@ public class QHybridSupport extends QHybridBaseSupport {
|
||||
|
||||
private PackageConfigHelper helper;
|
||||
|
||||
private volatile boolean searchDevice = false;
|
||||
public volatile boolean searchDevice = false;
|
||||
|
||||
private long timeOffset;
|
||||
|
||||
@ -511,35 +511,7 @@ public class QHybridSupport extends QHybridBaseSupport {
|
||||
|
||||
@Override
|
||||
public void onFindDevice(boolean start) {
|
||||
try {
|
||||
if (watchAdapter.supportsExtendedVibration()) {
|
||||
GB.toast("Device does not support brr brr", Toast.LENGTH_SHORT, GB.INFO);
|
||||
}
|
||||
} catch (UnsupportedOperationException e) {
|
||||
notifiyException(e);
|
||||
GB.toast("Please contact dakhnod@gmail.com\n", Toast.LENGTH_SHORT, GB.INFO);
|
||||
}
|
||||
|
||||
if (start && searchDevice) return;
|
||||
|
||||
searchDevice = start;
|
||||
|
||||
if (start) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int i = 0;
|
||||
while (searchDevice) {
|
||||
QHybridSupport.this.watchAdapter.vibrateFindMyDevicePattern();
|
||||
try {
|
||||
Thread.sleep(2500);
|
||||
} catch (InterruptedException e) {
|
||||
GB.log("error", GB.ERROR, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
watchAdapter.onFindDevice(start);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -121,4 +121,7 @@ public abstract class WatchAdapter {
|
||||
|
||||
public void onSetCallState(CallSpec callSpec) {
|
||||
}
|
||||
|
||||
public void onFindDevice(boolean start) {
|
||||
}
|
||||
}
|
||||
|
@ -516,6 +516,39 @@ public class FossilWatchAdapter extends WatchAdapter {
|
||||
public void handleHeartRateCharacteristic(BluetoothGattCharacteristic characteristic) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFindDevice(boolean start) {
|
||||
try {
|
||||
if (this.supportsExtendedVibration()) {
|
||||
GB.toast("Device does not support brr brr", Toast.LENGTH_SHORT, GB.INFO);
|
||||
}
|
||||
} catch (UnsupportedOperationException e) {
|
||||
getDeviceSupport().notifiyException(e);
|
||||
GB.toast("Please contact dakhnod@gmail.com\n", Toast.LENGTH_SHORT, GB.INFO);
|
||||
}
|
||||
|
||||
if (start && getDeviceSupport().searchDevice) return;
|
||||
|
||||
getDeviceSupport().searchDevice = start;
|
||||
|
||||
if (start) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int i = 0;
|
||||
while (getDeviceSupport().searchDevice) {
|
||||
vibrateFindMyDevicePattern();
|
||||
try {
|
||||
Thread.sleep(2500);
|
||||
} catch (InterruptedException e) {
|
||||
GB.log("error", GB.ERROR, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleBackgroundCharacteristic(BluetoothGattCharacteristic characteristic) {
|
||||
byte[] value = characteristic.getValue();
|
||||
switch (value[1]) {
|
||||
|
@ -24,6 +24,7 @@ import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
|
||||
@ -36,6 +37,8 @@ import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.Transaction;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil.FossilWatchAdapter;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.FossilRequest;
|
||||
@ -429,6 +432,25 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFindDevice(boolean start) {
|
||||
if(start){
|
||||
new TransactionBuilder("vibrate find")
|
||||
.write(
|
||||
getDeviceSupport().getCharacteristic(UUID.fromString("3dda0005-957f-7d4a-34a6-74696673696d")),
|
||||
new byte[]{(byte) 0x01, (byte) 0x04, (byte) 0x30, (byte) 0x75, (byte) 0x00, (byte) 0x00}
|
||||
)
|
||||
.queue(getDeviceSupport().getQueue());
|
||||
}else{
|
||||
new TransactionBuilder("vibrate find")
|
||||
.write(
|
||||
getDeviceSupport().getCharacteristic(UUID.fromString("3dda0005-957f-7d4a-34a6-74696673696d")),
|
||||
new byte[]{(byte) 0x02, (byte) 0x05, (byte) 0x04}
|
||||
)
|
||||
.queue(getDeviceSupport().getQueue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetCallState(CallSpec callSpec) {
|
||||
super.onSetCallState(callSpec);
|
||||
|
Loading…
Reference in New Issue
Block a user