NO.1 F1: Moved code for setting time into appropriate method.
This commit is contained in:
parent
440d1e6a81
commit
895c19cc1c
|
@ -171,7 +171,23 @@ public class No1F1Support extends AbstractBTLEDeviceSupport {
|
|||
|
||||
@Override
|
||||
public void onSetTime() {
|
||||
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("setTime");
|
||||
Calendar c = GregorianCalendar.getInstance();
|
||||
byte[] datetimeBytes = new byte[]{
|
||||
No1F1Constants.CMD_DATETIME,
|
||||
(byte) ((c.get(Calendar.YEAR) / 256) & 0xff),
|
||||
(byte) (c.get(Calendar.YEAR) % 256),
|
||||
(byte) (c.get(Calendar.MONTH) + 1),
|
||||
(byte) c.get(Calendar.DAY_OF_MONTH),
|
||||
(byte) c.get(Calendar.HOUR_OF_DAY),
|
||||
(byte) c.get(Calendar.MINUTE),
|
||||
(byte) c.get(Calendar.SECOND)
|
||||
};
|
||||
builder.write(ctrlCharacteristic, datetimeBytes);
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error setting time: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -363,20 +379,6 @@ public class No1F1Support extends AbstractBTLEDeviceSupport {
|
|||
private void sendSettings(TransactionBuilder builder) {
|
||||
// TODO Create custom settings page for changing hardcoded values
|
||||
|
||||
// set date and time
|
||||
Calendar c = GregorianCalendar.getInstance();
|
||||
byte[] datetimeBytes = new byte[]{
|
||||
No1F1Constants.CMD_DATETIME,
|
||||
(byte) ((c.get(Calendar.YEAR) / 256) & 0xff),
|
||||
(byte) (c.get(Calendar.YEAR) % 256),
|
||||
(byte) (c.get(Calendar.MONTH) + 1),
|
||||
(byte) c.get(Calendar.DAY_OF_MONTH),
|
||||
(byte) c.get(Calendar.HOUR_OF_DAY),
|
||||
(byte) c.get(Calendar.MINUTE),
|
||||
(byte) c.get(Calendar.SECOND)
|
||||
};
|
||||
builder.write(ctrlCharacteristic, datetimeBytes);
|
||||
|
||||
// set user data
|
||||
ActivityUser activityUser = new ActivityUser();
|
||||
byte[] userBytes = new byte[]{
|
||||
|
|
Loading…
Reference in New Issue