Skip to content

Commit

Permalink
api v3.4.7 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
scaryghost committed May 14, 2018
1 parent e5e3506 commit b5d9d75
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.android.tools.build:gradle:3.1.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ android {
defaultConfig {
minSdkVersion 18
targetSdkVersion 27
versionCode 56
versionName "3.4.6"
versionCode 57
versionName "3.4.7"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,29 +523,32 @@ private Task<File> downloadFirmware(Pair<Version, String> latest) {

@Override
public Task<File> downloadFirmwareAsync(final String version) {
if (connected) {
if (version == null) {
File info1Json = io.findDownloadedFile("info1.json");
if (!info1Json.exists() || info1Json.lastModified() < Calendar.getInstance().getTimeInMillis() - RELEASE_INFO_TTL) {
return io.downloadFileAsync(String.format(Locale.US, "%s/metawear/info1.json", RELEASES_URL), "info1.json")
.onSuccessTask(task -> downloadFirmware(findRelease(task.getResult())));
} else {
try {
Pair<Version, String> latest = findRelease(info1Json);
File firmware = io.findDownloadedFile(buildFirmwareFileName(latest));
return !firmware.exists() ? downloadFirmware(latest) : Task.forResult(firmware);
} catch (Exception e) {
return Task.forError(e);
}
}
if (persist.boardInfo.hardwareRevision == null) {
return Task.forError(new IllegalStateException("Hardware revision unavailable"));
}
if (persist.boardInfo.modelNumber == null) {
return Task.forError(new IllegalStateException("Model number unavailable"));
}
if (version == null) {
File info1Json = io.findDownloadedFile("info1.json");
if (!info1Json.exists() || info1Json.lastModified() < Calendar.getInstance().getTimeInMillis() - RELEASE_INFO_TTL) {
return io.downloadFileAsync(String.format(Locale.US, "%s/metawear/info1.json", RELEASES_URL), "info1.json")
.onSuccessTask(task -> downloadFirmware(findRelease(task.getResult())));
} else {
final Version versionObj = new Version(version);
return downloadFirmware(new Pair<>(versionObj, "firmware.zip"))
.continueWithTask(task -> task.isFaulted() ? downloadFirmware(new Pair<>(versionObj, "firmware.bin")) : task)
.continueWithTask(task -> task.isFaulted() ? Task.forError(new RuntimeException("Firmware version \'" + version + "\' not available for this board", task.getError())) : task);
try {
Pair<Version, String> latest = findRelease(info1Json);
File firmware = io.findDownloadedFile(buildFirmwareFileName(latest));
return !firmware.exists() ? downloadFirmware(latest) : Task.forResult(firmware);
} catch (Exception e) {
return Task.forError(e);
}
}
} else {
final Version versionObj = new Version(version);
return downloadFirmware(new Pair<>(versionObj, "firmware.zip"))
.continueWithTask(task -> task.isFaulted() ? downloadFirmware(new Pair<>(versionObj, "firmware.bin")) : task)
.continueWithTask(task -> task.isFaulted() ? Task.forError(new RuntimeException("Firmware version \'" + version + "\' not available for this board", task.getError())) : task);
}
return Task.forError(new IllegalStateException("No active BLE connection"));
}
@Override
public Task<File> downloadLatestFirmwareAsync() {
Expand Down Expand Up @@ -752,6 +755,7 @@ public Task<Void> connectAsync() {

if (task.isFaulted()) {
if (inMetaBootMode()) {
connected = true;
return Task.forResult(null);
} else {
if (task.getError() instanceof TaskTimeoutException) {
Expand Down

0 comments on commit b5d9d75

Please sign in to comment.