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;
|
mIsConnected = true;
|
||||||
|
|
||||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
||||||
if (sharedPrefs.getBoolean("datetime_synconconnect", true)) {
|
|
||||||
LOG.info("syncing time");
|
|
||||||
write(mPebbleProtocol.encodeSetTime(-1));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,6 +305,13 @@ public class PebbleIoThread extends GBDeviceIoThread {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
|
|
||||||
switch (deviceCmd.commandClass) {
|
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:
|
case APP_MANAGEMENT_RES:
|
||||||
GBDeviceCommandAppManagementResult appMgmtRes = (GBDeviceCommandAppManagementResult) deviceCmd;
|
GBDeviceCommandAppManagementResult appMgmtRes = (GBDeviceCommandAppManagementResult) deviceCmd;
|
||||||
switch (appMgmtRes.type) {
|
switch (appMgmtRes.type) {
|
||||||
|
@ -411,6 +412,18 @@ public class PebbleIoThread extends GBDeviceIoThread {
|
||||||
|
|
||||||
if (mPBWReader.isFirmware()) {
|
if (mPBWReader.isFirmware()) {
|
||||||
writeInstallApp(mPebbleProtocol.encodeInstallFirmwareStart());
|
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");
|
LOG.info("starting firmware installation");
|
||||||
mInstallSlot = 0;
|
mInstallSlot = 0;
|
||||||
mInstallState = PebbleAppInstallState.START_INSTALL;
|
mInstallState = PebbleAppInstallState.START_INSTALL;
|
||||||
|
|
|
@ -28,9 +28,6 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(PebbleProtocol.class);
|
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_FIRMWARE = 1;
|
||||||
static final short ENDPOINT_TIME = 11;
|
static final short ENDPOINT_TIME = 11;
|
||||||
static final short ENDPOINT_FIRMWAREVERSION = 16;
|
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_UPLOADCANCEL = 5;
|
||||||
static final short LENGTH_SYSTEMMESSAGE = 2;
|
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();
|
private static Random mRandom = new Random();
|
||||||
|
|
||||||
|
boolean isFw3x = true;
|
||||||
byte last_id = -1;
|
byte last_id = -1;
|
||||||
private ArrayList<UUID> tmpUUIDS = new ArrayList<>();
|
private ArrayList<UUID> tmpUUIDS = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -224,7 +221,8 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||||
ts += (SimpleTimeZone.getDefault().getOffset(ts));
|
ts += (SimpleTimeZone.getDefault().getOffset(ts));
|
||||||
ts /= 1000;
|
ts /= 1000;
|
||||||
|
|
||||||
if (USE_OLD_NOTIFICATION_PROTOCOL) {
|
|
||||||
|
if (!isFw3x || true) { // remove || true if necessary on FW 3.x
|
||||||
String[] parts = {from, body, ts.toString()};
|
String[] parts = {from, body, ts.toString()};
|
||||||
return encodeMessage(ENDPOINT_NOTIFICATION, NOTIFICATION_SMS, 0, parts);
|
return encodeMessage(ENDPOINT_NOTIFICATION, NOTIFICATION_SMS, 0, parts);
|
||||||
}
|
}
|
||||||
|
@ -682,6 +680,10 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||||
buf.get(tmp, 0, 32);
|
buf.get(tmp, 0, 32);
|
||||||
|
|
||||||
versionCmd.fwVersion = new String(tmp).trim();
|
versionCmd.fwVersion = new String(tmp).trim();
|
||||||
|
if (versionCmd.fwVersion.startsWith("3.")) {
|
||||||
|
isFw3x = true;
|
||||||
|
}
|
||||||
|
|
||||||
buf.get(tmp, 0, 9);
|
buf.get(tmp, 0, 9);
|
||||||
Byte hwRev = buf.get();
|
Byte hwRev = buf.get();
|
||||||
if (hwRev > 0 && hwRev < hwRevisions.length) {
|
if (hwRev > 0 && hwRev < hwRevisions.length) {
|
||||||
|
|
Loading…
Reference in New Issue