mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-09-01 20:15:52 +02:00
Pebble: Make firmware installation possible from recovery (Closes #54)
Also make HW revision displayable for Pebble Time.
This commit is contained in:
parent
824a88c55f
commit
dfcad94c2c
@ -120,12 +120,6 @@ public class PebbleIoThread extends GBDeviceIoThread {
|
||||
|
||||
mIsConnected = true;
|
||||
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
if (sharedPrefs.getBoolean("datetime_synconconnect", true)) {
|
||||
LOG.info("syncing time");
|
||||
write(mPebbleProtocol.encodeSetTime(-1));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -311,6 +305,13 @@ public class PebbleIoThread extends GBDeviceIoThread {
|
||||
Context context = getContext();
|
||||
|
||||
switch (deviceCmd.commandClass) {
|
||||
case VERSION_INFO:
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
if (sharedPrefs.getBoolean("datetime_synconconnect", true)) {
|
||||
LOG.info("syncing time");
|
||||
write(mPebbleProtocol.encodeSetTime(-1));
|
||||
}
|
||||
return false;
|
||||
case APP_MANAGEMENT_RES:
|
||||
GBDeviceCommandAppManagementResult appMgmtRes = (GBDeviceCommandAppManagementResult) deviceCmd;
|
||||
switch (appMgmtRes.type) {
|
||||
@ -411,6 +412,18 @@ public class PebbleIoThread extends GBDeviceIoThread {
|
||||
|
||||
if (mPBWReader.isFirmware()) {
|
||||
writeInstallApp(mPebbleProtocol.encodeInstallFirmwareStart());
|
||||
|
||||
/*
|
||||
* This is a hack for recovery mode, in which the blocking read has no timeout and the
|
||||
* firmware installation command does not return any ack.
|
||||
* In normal mode we would got at least out of the blocking read call after a while.
|
||||
*
|
||||
*
|
||||
* ... we should really not handle installation from thread that does the blocking read
|
||||
*
|
||||
*/
|
||||
writeInstallApp(mPebbleProtocol.encodeGetTime());
|
||||
|
||||
LOG.info("starting firmware installation");
|
||||
mInstallSlot = 0;
|
||||
mInstallState = PebbleAppInstallState.START_INSTALL;
|
||||
|
@ -28,9 +28,6 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(PebbleProtocol.class);
|
||||
|
||||
// set to false AT YOUR OWN RISK. I ended up in recovery
|
||||
static private final boolean USE_OLD_NOTIFICATION_PROTOCOL = true;
|
||||
|
||||
static final short ENDPOINT_FIRMWARE = 1;
|
||||
static final short ENDPOINT_TIME = 11;
|
||||
static final short ENDPOINT_FIRMWAREVERSION = 16;
|
||||
@ -164,10 +161,10 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
static final short LENGTH_UPLOADCANCEL = 5;
|
||||
static final short LENGTH_SYSTEMMESSAGE = 2;
|
||||
|
||||
private static final String[] hwRevisions = {"unknown", "ev1", "ev2", "ev2_3", "ev2_4", "v1_5", "v2_0"};
|
||||
private static final String[] hwRevisions = {"unknown", "ev1", "ev2", "ev2_3", "ev2_4", "v1_5", "v2_0", "evt2", "dvt"};
|
||||
private static Random mRandom = new Random();
|
||||
|
||||
|
||||
boolean isFw3x = true;
|
||||
byte last_id = -1;
|
||||
private ArrayList<UUID> tmpUUIDS = new ArrayList<>();
|
||||
|
||||
@ -224,7 +221,8 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
ts += (SimpleTimeZone.getDefault().getOffset(ts));
|
||||
ts /= 1000;
|
||||
|
||||
if (USE_OLD_NOTIFICATION_PROTOCOL) {
|
||||
|
||||
if (!isFw3x || true) { // remove || true if necessary on FW 3.x
|
||||
String[] parts = {from, body, ts.toString()};
|
||||
return encodeMessage(ENDPOINT_NOTIFICATION, NOTIFICATION_SMS, 0, parts);
|
||||
}
|
||||
@ -682,6 +680,10 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
buf.get(tmp, 0, 32);
|
||||
|
||||
versionCmd.fwVersion = new String(tmp).trim();
|
||||
if (versionCmd.fwVersion.startsWith("3.")) {
|
||||
isFw3x = true;
|
||||
}
|
||||
|
||||
buf.get(tmp, 0, 9);
|
||||
Byte hwRev = buf.get();
|
||||
if (hwRev > 0 && hwRev < hwRevisions.length) {
|
||||
|
Loading…
Reference in New Issue
Block a user