mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-26 00:21:45 +01:00
added json button configuration
This commit is contained in:
parent
4c11a886fe
commit
4ee2b006b7
@ -478,7 +478,7 @@ public class FossilWatchAdapter extends WatchAdapter {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void handleBackgroundCharacteristic(BluetoothGattCharacteristic characteristic) {
|
||||
protected void handleBackgroundCharacteristic(BluetoothGattCharacteristic characteristic) {
|
||||
byte[] value = characteristic.getValue();
|
||||
switch (value[1]) {
|
||||
case 2: {
|
||||
|
@ -1,6 +1,12 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil_hr;
|
||||
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
@ -14,9 +20,11 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fos
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.SetDeviceStateRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.notification.PlayNotificationRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.authentication.VerifyPrivateKeyRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.buttons.ButtonConfigurationPutRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.configuration.ConfigurationGetRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.notification.NotificationFilterPutHRRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.notification.NotificationImagePutRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
private byte[] secretKey = new byte[]{(byte) 0x60, (byte) 0x26, (byte) 0xB7, (byte) 0xFD, (byte) 0xB2, (byte) 0x6D, (byte) 0x05, (byte) 0x5E, (byte) 0xDA, (byte) 0xF7, (byte) 0x4B, (byte) 0x49, (byte) 0x98, (byte) 0x78, (byte) 0x02, (byte) 0x38};
|
||||
@ -71,6 +79,8 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
|
||||
syncSettings();
|
||||
|
||||
queueWrite(new ButtonConfigurationPutRequest(this));
|
||||
|
||||
queueWrite(new SetDeviceStateRequest(GBDevice.State.INITIALIZED));
|
||||
}
|
||||
|
||||
@ -127,4 +137,24 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
public byte[] getWatchRandomNumber() {
|
||||
return watchRandomNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleBackgroundCharacteristic(BluetoothGattCharacteristic characteristic) {
|
||||
super.handleBackgroundCharacteristic(characteristic);
|
||||
|
||||
byte[] value = characteristic.getValue();
|
||||
|
||||
int eventId = value[2];
|
||||
|
||||
try {
|
||||
JSONObject requestJson = new JSONObject(new String(value, 3, value.length - 3));
|
||||
|
||||
String action = requestJson.getJSONObject("commuteApp._.config.commute_info")
|
||||
.getString("dest");
|
||||
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,67 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.buttons;
|
||||
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil.FossilWatchAdapter;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.json.JsonPutRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
public class ButtonConfigurationPutRequest extends JsonPutRequest {
|
||||
public ButtonConfigurationPutRequest(FossilWatchAdapter adapter) {
|
||||
super((short) 0x0500, createObject(), adapter);
|
||||
}
|
||||
|
||||
private static JSONObject createObject() {
|
||||
try {
|
||||
return new JSONObject()
|
||||
.put("push", new JSONObject()
|
||||
.put("set", new JSONObject()
|
||||
.put("commuteApp._.config.destinations", new JSONArray()
|
||||
.put("LAMP 1")
|
||||
.put("LAMP 3")
|
||||
.put("LAMP 4")
|
||||
.put("LAMP 5")
|
||||
.put("LAMP 6")
|
||||
.put("LAMP 7")
|
||||
.put("LAMP 8")
|
||||
.put("LAMP 9")
|
||||
.put("LAMP 10")
|
||||
.put("LAMP 11")
|
||||
.put("LAMP 12")
|
||||
.put("LAMP 13")
|
||||
.put("LAMP 14")
|
||||
.put("LAMP 8")
|
||||
.put("LAMP 9")
|
||||
.put("LAMP 10")
|
||||
.put("LAMP 11")
|
||||
.put("LAMP 12")
|
||||
.put("LAMP 13")
|
||||
.put("LAMP 14")
|
||||
)
|
||||
.put("master._.config.buttons", new JSONArray()
|
||||
.put(new JSONObject()
|
||||
.put("name", "commuteApp")
|
||||
.put("button_evt", "top_short_press_release")
|
||||
)
|
||||
.put(new JSONObject()
|
||||
.put("name", "commuteApp")
|
||||
.put("button_evt", "middle_short_press_release")
|
||||
)
|
||||
.put(new JSONObject()
|
||||
.put("name", "commuteApp")
|
||||
.put("button_evt", "bottom_short_press_release")
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
} catch (JSONException e) {
|
||||
GB.toast("error creating json", Toast.LENGTH_LONG, GB.ERROR, e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user