mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-01 06:22:55 +01:00
performConnected() -> builder.qeueue(getQueue())
This commit is contained in:
parent
c69be1f94b
commit
fb85326939
@ -110,9 +110,14 @@ public abstract class AbstractBTLEDeviceSupport extends AbstractDeviceSupport im
|
||||
/**
|
||||
* Send commands like this to the device:
|
||||
* <p>
|
||||
* <code>perform("sms notification").write(someCharacteristic, someByteArray).queue(getQueue());</code>
|
||||
* <code>performInitialized("sms notification").write(someCharacteristic, someByteArray).queue(getQueue());</code>
|
||||
* </p>
|
||||
* TODO: support orchestration of multiple reads and writes depending on returned values
|
||||
* This will asynchronously
|
||||
* <ul>
|
||||
* <li>connect to the device (if necessary)</li>
|
||||
* <li>initialize the device (if necessary)</li>
|
||||
* <li>execute the commands collected with the returned transaction builder</li>
|
||||
* </ul>
|
||||
*
|
||||
* @see #performConnected(Transaction)
|
||||
* @see #initializeDevice(TransactionBuilder)
|
||||
@ -133,6 +138,11 @@ public abstract class AbstractBTLEDeviceSupport extends AbstractDeviceSupport im
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the device is connected and (only then) performs the actions of the given
|
||||
* transaction builder.
|
||||
*
|
||||
* In contrast to {@link #performInitialized(String)}, no initialization sequence is performed
|
||||
* with the device, only the actions of the given builder are executed.
|
||||
* @param transaction
|
||||
* @throws IOException
|
||||
* @see {@link #performInitialized(String)}
|
||||
|
@ -415,7 +415,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
setCurrentDate(builder);
|
||||
setCurrentTime(builder);
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
}catch(IOException e){
|
||||
|
||||
}
|
||||
@ -446,7 +446,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
|
||||
setAlarm(builder, null);
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
|
||||
GB.toast(getContext(), getContext().getString(R.string.user_feedback_all_alarms_disabled), Toast.LENGTH_SHORT, GB.INFO);
|
||||
}catch(Exception e){}
|
||||
@ -532,7 +532,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
TransactionBuilder builder = performInitialized("Shutdown");
|
||||
builder.write(ctrlCharacteristic, new byte[]{HPlusConstants.CMD_SHUTDOWN, HPlusConstants.ARG_SHUTDOWN_EN});
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
@ -545,7 +545,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||
TransactionBuilder builder = performInitialized("HeartRateTest");
|
||||
|
||||
builder.write(ctrlCharacteristic, new byte[]{HPlusConstants.CMD_SET_HEARTRATE_STATE, HPlusConstants.ARG_HEARTRATE_MEASURE_ON}); //Set Real Time... ?
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
@ -563,7 +563,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||
state = HPlusConstants.ARG_HEARTRATE_ALLDAY_OFF;
|
||||
|
||||
builder.write(ctrlCharacteristic, new byte[]{HPlusConstants.CMD_SET_ALLDAY_HRM, state});
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
@ -575,7 +575,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||
TransactionBuilder builder = performInitialized("findMe");
|
||||
|
||||
setFindMe(builder, start);
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error toggling Find Me: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
@ -591,10 +591,10 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||
msg[0] = HPlusConstants.CMD_SET_INCOMING_CALL_NUMBER;
|
||||
|
||||
for (int i = 0; i < msg.length - 1; i++)
|
||||
msg[i + 1] = (byte) "GadgetBridge".charAt(i);
|
||||
msg[i + 1] = (byte) "Gadgetbridge".charAt(i);
|
||||
|
||||
builder.write(ctrlCharacteristic, msg);
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error setting Vibration: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
@ -711,7 +711,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||
builder.write(ctrlCharacteristic, msg);
|
||||
}
|
||||
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error showing incoming call: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
|
||||
@ -774,7 +774,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||
msg[2] = (byte) remaining;
|
||||
|
||||
builder.write(ctrlCharacteristic, msg);
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error showing device Notification: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class ID115Support extends AbstractBTLEDeviceSupport {
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("time");
|
||||
setTime(builder);
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
} catch(IOException e) {
|
||||
LOG.warn("Unable to send current time", e);
|
||||
}
|
||||
@ -193,7 +193,7 @@ public class ID115Support extends AbstractBTLEDeviceSupport {
|
||||
builder.write(normalWriteCharacteristic, new byte[] {
|
||||
ID115Constants.CMD_ID_DEVICE_RESTART, ID115Constants.CMD_KEY_REBOOT
|
||||
});
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
} catch(Exception e) {
|
||||
}
|
||||
}
|
||||
@ -350,7 +350,7 @@ public class ID115Support extends AbstractBTLEDeviceSupport {
|
||||
ID115Constants.CMD_KEY_NOTIFY_STOP,
|
||||
1
|
||||
});
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
} catch(IOException e) {
|
||||
LOG.warn("Unable to stop call notification", e);
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ public class TeclastH30Support extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
builder.write(ctrlCharacteristic, currentPacket);
|
||||
}
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
LOG.warn(e.getMessage());
|
||||
}
|
||||
@ -284,7 +284,7 @@ public class TeclastH30Support extends AbstractBTLEDeviceSupport {
|
||||
alarms.get(i).isEnabled() ? cal.get(Calendar.MINUTE) : -1
|
||||
));
|
||||
}
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
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) {
|
||||
LOG.warn(e.getMessage());
|
||||
@ -296,7 +296,7 @@ public class TeclastH30Support extends AbstractBTLEDeviceSupport {
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("SetTime");
|
||||
syncDateAndTime(builder);
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
} catch(IOException e) {
|
||||
LOG.warn(e.getMessage());
|
||||
}
|
||||
@ -373,7 +373,7 @@ public class TeclastH30Support extends AbstractBTLEDeviceSupport {
|
||||
builder.write(ctrlCharacteristic, commandWithChecksum(
|
||||
JYouConstants.CMD_ACTION_REBOOT_DEVICE, 0, 0
|
||||
));
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
} catch(Exception e) {
|
||||
LOG.warn(e.getMessage());
|
||||
}
|
||||
@ -386,7 +386,7 @@ public class TeclastH30Support extends AbstractBTLEDeviceSupport {
|
||||
builder.write(ctrlCharacteristic, commandWithChecksum(
|
||||
JYouConstants.CMD_ACTION_HEARTRATE_SWITCH, 0, 1
|
||||
));
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
} catch(Exception e) {
|
||||
LOG.warn(e.getMessage());
|
||||
}
|
||||
@ -400,7 +400,7 @@ public class TeclastH30Support extends AbstractBTLEDeviceSupport {
|
||||
builder.write(ctrlCharacteristic, commandWithChecksum(
|
||||
JYouConstants.CMD_SET_HEARTRATE_AUTO, 0, enable ? 1 : 0
|
||||
));
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
} catch(Exception e) {
|
||||
LOG.warn(e.getMessage());
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ public class No1F1Support extends AbstractBTLEDeviceSupport {
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("setTime");
|
||||
setTime(builder);
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error setting time: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
@ -308,7 +308,7 @@ public class No1F1Support extends AbstractBTLEDeviceSupport {
|
||||
(byte) 0x11
|
||||
};
|
||||
builder.write(ctrlCharacteristic, msg);
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error starting heart rate measurement: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
@ -500,7 +500,7 @@ public class No1F1Support extends AbstractBTLEDeviceSupport {
|
||||
1
|
||||
};
|
||||
builder.write(ctrlCharacteristic, msg);
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
LOG.warn("Unable to set vibration", e);
|
||||
}
|
||||
@ -514,7 +514,7 @@ public class No1F1Support extends AbstractBTLEDeviceSupport {
|
||||
(byte) iconId
|
||||
};
|
||||
builder.write(ctrlCharacteristic, msg);
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error showing icon: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
@ -546,7 +546,7 @@ public class No1F1Support extends AbstractBTLEDeviceSupport {
|
||||
System.arraycopy(bytes, 0, msg, 2, length);
|
||||
builder.write(ctrlCharacteristic, msg);
|
||||
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error showing notificaton: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
@ -560,7 +560,7 @@ public class No1F1Support extends AbstractBTLEDeviceSupport {
|
||||
No1F1Constants.NOTIFICATION_STOP
|
||||
};
|
||||
builder.write(ctrlCharacteristic, msg);
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
LOG.warn("Unable to stop notification", e);
|
||||
}
|
||||
@ -578,7 +578,7 @@ public class No1F1Support extends AbstractBTLEDeviceSupport {
|
||||
(byte) 0xfa
|
||||
};
|
||||
builder.write(ctrlCharacteristic, msg);
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error fetching activity data: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
|
@ -455,7 +455,7 @@ public class XWatchSupport extends AbstractBTLEDeviceSupport {
|
||||
try {
|
||||
builder = performInitialized("fetchActivityData");
|
||||
requestDetailedData(builder);
|
||||
performConnected(builder.getTransaction());
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error fetching activity data: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user