-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from NordicSemiconductor/feature/suit-push
Feature: Adding support for pushing cache images for SUIT updates
- Loading branch information
Showing
23 changed files
with
856 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
mcumgr-core/src/main/java/io/runtime/mcumgr/dfu/suit/model/CacheImage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.runtime.mcumgr.dfu.suit.model; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** @noinspection unused*/ | ||
public class CacheImage { | ||
|
||
/** Target partition ID. */ | ||
public final int partitionId; | ||
|
||
/** | ||
* The image. | ||
*/ | ||
public final byte @NotNull [] image; | ||
|
||
/** | ||
* A wrapper for a partition cache raw image and the ID of the partition. | ||
* | ||
* @param partition the partition ID. | ||
* @param data the signed binary to be sent. | ||
*/ | ||
public CacheImage(int partition, byte @NotNull [] data) { | ||
this.partitionId = partition; | ||
this.image = data; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
mcumgr-core/src/main/java/io/runtime/mcumgr/dfu/suit/model/CacheImageSet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package io.runtime.mcumgr.dfu.suit.model; | ||
|
||
import android.util.Pair; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** @noinspection unused*/ | ||
public class CacheImageSet { | ||
@NotNull | ||
private final List<CacheImage> images; | ||
|
||
/** | ||
* Creates an empty image set. Use {@link #add(CacheImage)} to add targets. | ||
*/ | ||
public CacheImageSet() { | ||
this.images = new ArrayList<>(4); | ||
} | ||
|
||
/** | ||
* Creates an image set with given targets. | ||
* @param targets image targets. | ||
*/ | ||
public CacheImageSet(@NotNull final List<CacheImage> targets) { | ||
this.images = targets; | ||
} | ||
|
||
/** | ||
* Returns list of targets. | ||
*/ | ||
@NotNull | ||
public List<CacheImage> getImages() { | ||
return images; | ||
} | ||
|
||
public CacheImageSet add(CacheImage image) { | ||
images.add(image); | ||
return this; | ||
} | ||
|
||
public CacheImageSet add(int partition, byte[] image) { | ||
images.add(new CacheImage(partition, image)); | ||
return this; | ||
} | ||
|
||
public CacheImageSet add(Pair<Integer, byte[]> image) { | ||
images.add(new CacheImage(image.first, image.second)); | ||
return this; | ||
} | ||
|
||
public CacheImageSet add(List<Pair<Integer, byte[]>> images) { | ||
for (Pair<Integer, byte[]> image : images) | ||
this.images.add(new CacheImage(image.first, image.second)); | ||
return this; | ||
} | ||
} |
Oops, something went wrong.