19 | * This callback is used to pass the upgrade controller which can pause/resume/cancel 20 | * an upgrade to a controller which may not have access to the original object. 21 | * 22 | * @param controller the upgrade controller. 23 | */ 24 | void onUpgradeStarted(FirmwareUpgradeController controller); 25 | 26 | /** 27 | * Called when the firmware upgrade changes state. 28 | * 29 | * @param prevState previous state. 30 | * @param newState new state. 31 | * @see FirmwareUpgradeManager.State 32 | */ 33 | void onStateChanged(FirmwareUpgradeManager.State prevState, 34 | FirmwareUpgradeManager.State newState); 35 | 36 | /** 37 | * Called when the firmware upgrade has succeeded. 38 | */ 39 | void onUpgradeCompleted(); 40 | 41 | /** 42 | * Called when the firmware upgrade has failed. 43 | * 44 | * @param state the state the upgrade failed in. 45 | * @param error the error. 46 | */ 47 | void onUpgradeFailed(FirmwareUpgradeManager.State state, McuMgrException error); 48 | 49 | /** 50 | * Called when the firmware upgrade has been canceled using the 51 | * {@link FirmwareUpgradeManager#cancel()} method. The upgrade may be cancelled only during 52 | * uploading the image. When the image is uploaded, the test and/or confirm commands will be 53 | * sent depending on the {@link FirmwareUpgradeManager#setMode(FirmwareUpgradeManager.Mode)}. 54 | * 55 | * @param state the state the upgrade was cancelled in. 56 | */ 57 | void onUpgradeCanceled(FirmwareUpgradeManager.State state); 58 | 59 | /** 60 | * Called when the {@link FirmwareUpgradeManager.State#UPLOAD} state progress has changed. 61 | * 62 | * @param bytesSent the number of bytes sent so far. 63 | * @param imageSize the total number of bytes to send. 64 | * @param timestamp the time that the successful response packet for the progress was received. 65 | */ 66 | void onUploadProgressChanged(int bytesSent, int imageSize, long timestamp); 67 | } 68 | -------------------------------------------------------------------------------- /mcumgr-core/src/main/java/io/runtime/mcumgr/dfu/FirmwareUpgradeController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 Runtime Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | package io.runtime.mcumgr.dfu; 8 | 9 | @SuppressWarnings("unused") 10 | public interface FirmwareUpgradeController { 11 | 12 | /** 13 | * Pause the firmware upgrade. 14 | */ 15 | void pause(); 16 | 17 | /** 18 | * Resume a paused firmware upgrade. 19 | */ 20 | void resume(); 21 | 22 | /** 23 | * Cancel the firmware upgrade. 24 | * The firmware may be cancelled in 25 | * {@link FirmwareUpgradeManager.State#VALIDATE} or 26 | * {@link FirmwareUpgradeManager.State#UPLOAD} state. 27 | * The manager does not try to recover the original firmware after the test or confirm commands 28 | * have been sent. To undo the upload, confirm the image that have been moved to slot 1 during 29 | * swap. 30 | */ 31 | void cancel(); 32 | 33 | /** 34 | * Determine whether the firmware upgrade is paused. 35 | * 36 | * @return True if the firmware upgrade is paused, false otherwise. 37 | */ 38 | boolean isPaused(); 39 | 40 | /** 41 | * Determine whether the firmware upgrade is in progress. 42 | * 43 | * @return True if the firmware upgrade is in progress, false otherwise. 44 | */ 45 | boolean isInProgress(); 46 | } 47 | -------------------------------------------------------------------------------- /mcumgr-core/src/main/java/io/runtime/mcumgr/exception/InsufficientMtuException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 Runtime Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | package io.runtime.mcumgr.exception; 8 | 9 | import io.runtime.mcumgr.dfu.FirmwareUpgradeManager; 10 | 11 | /** 12 | * InsufficientMtuExceptions should be thrown by the transporter when the packet from the manager 13 | * is too large to be sent or (potentially) fragmented. The exception includes the transporter's 14 | * MTU. This is used in practice by the {@link FirmwareUpgradeManager} to resize it's packets to 15 | * fit within the transporter's MTU. 16 | */ 17 | @SuppressWarnings("unused") 18 | public class InsufficientMtuException extends McuMgrException { 19 | private int mMtu; 20 | private int mDataLength; 21 | 22 | public InsufficientMtuException(int payloadLength, int mtu) { 23 | super("Payload (" + payloadLength + " bytes) too long for MTU: " + mtu); 24 | mDataLength = payloadLength; 25 | mMtu = mtu; 26 | } 27 | 28 | public int getMtu() { 29 | return mMtu; 30 | } 31 | 32 | public int getDataLength() { 33 | return mDataLength; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /mcumgr-core/src/main/java/io/runtime/mcumgr/exception/McuMgrCoapException.java: -------------------------------------------------------------------------------- 1 | package io.runtime.mcumgr.exception; 2 | 3 | import io.runtime.mcumgr.McuMgrCallback; 4 | 5 | /** 6 | * A McuMgrException caused by a CoAP response error. For CoAP transport scheme McuMgr requests 7 | * which result in a CoAP response error, this exception will be thrown (for 8 | * synchronous requests) or the {@link McuMgrCallback#onError(McuMgrException)} will be called with 9 | * this exception (for asynchronous requests). 10 | * 11 | * This exception holds all the necessary information to determine the error code and reconstruct 12 | * the CoAP response. 13 | */ 14 | @SuppressWarnings("unused") 15 | public class McuMgrCoapException extends McuMgrException { 16 | private byte[] mBytes; 17 | private int mCodeClass; 18 | private int mCodeDetail; 19 | 20 | public McuMgrCoapException(byte[] bytes, int codeClass, int codeDetail) { 21 | super("McuManager CoAP request resulted in an error response: " + codeClass + ".0" + codeDetail); 22 | mBytes = bytes; 23 | mCodeClass = codeClass; 24 | mCodeDetail = codeDetail; 25 | } 26 | 27 | /** 28 | * Get the raw bytes of the response which caused this exception. 29 | * 30 | * @return The bytes of the response. 31 | */ 32 | public byte[] getBytes() { 33 | return mBytes; 34 | } 35 | 36 | /** 37 | * Get the response's code class. 38 | * 39 | * @return The response code class. 40 | */ 41 | public int getCodeClass() { 42 | return mCodeClass; 43 | } 44 | 45 | /** 46 | * Get the response's code detail. 47 | * 48 | * @return The response code detail. 49 | */ 50 | public int getCodeDetail() { 51 | return mCodeDetail; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /mcumgr-core/src/main/java/io/runtime/mcumgr/exception/McuMgrErrorException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 Runtime Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | package io.runtime.mcumgr.exception; 8 | 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | import io.runtime.mcumgr.McuMgrErrorCode; 12 | import io.runtime.mcumgr.dfu.FirmwareUpgradeManager; 13 | import io.runtime.mcumgr.response.McuMgrResponse; 14 | 15 | /** 16 | * Used to convey errors caused by an {@link McuMgrErrorCode} within a response. This is used in 17 | * practice by {@link FirmwareUpgradeManager} to send a failure callback with the 18 | * {@link McuMgrErrorCode} that caused the failure. 19 | */ 20 | @SuppressWarnings("unused") 21 | public class McuMgrErrorException extends McuMgrException { 22 | @NotNull 23 | private McuMgrErrorCode mCode; 24 | 25 | public McuMgrErrorException(@NotNull McuMgrErrorCode code) { 26 | super("Mcu Mgr Error: " + code); 27 | mCode = code; 28 | } 29 | 30 | public McuMgrErrorException(@NotNull McuMgrResponse response) { 31 | this(McuMgrErrorCode.valueOf(response.rc)); 32 | } 33 | 34 | /** 35 | * Get the code which caused this exception to be thrown. 36 | * 37 | * @return The McuManager response code which caused this exception to be thrown. 38 | */ 39 | @NotNull 40 | public McuMgrErrorCode getCode() { 41 | return mCode; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /mcumgr-core/src/main/java/io/runtime/mcumgr/exception/McuMgrException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 Runtime Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | package io.runtime.mcumgr.exception; 7 | 8 | /** 9 | * Essentially a renamed {@link Exception}. 10 | */ 11 | public class McuMgrException extends Exception { 12 | 13 | /** 14 | * Constructs a new exception with {@code null} as its detail message. 15 | * The cause is not initialized, and may subsequently be initialized by a 16 | * call to {@link #initCause}. 17 | */ 18 | public McuMgrException() { 19 | super(); 20 | } 21 | 22 | /** 23 | * Constructs a new exception with the specified detail message. The 24 | * cause is not initialized, and may subsequently be initialized by 25 | * a call to {@link #initCause}. 26 | * 27 | * @param message the detail message. The detail message is saved for 28 | * later retrieval by the {@link #getMessage()} method. 29 | */ 30 | public McuMgrException(String message) { 31 | super(message); 32 | } 33 | 34 | /** 35 | * Constructs a new exception with the specified detail message and 36 | * cause.
Note that the detail message associated with 37 | * {@code cause} is not automatically incorporated in 38 | * this exception's detail message. 39 | * 40 | * @param message the detail message (which is saved for later retrieval 41 | * by the {@link #getMessage()} method). 42 | * @param cause the cause (which is saved for later retrieval by the 43 | * {@link #getCause()} method). (A null value is 44 | * permitted, and indicates that the cause is nonexistent or 45 | * unknown.) 46 | * @since 1.4 47 | */ 48 | public McuMgrException(String message, Throwable cause) { 49 | super(message, cause); 50 | } 51 | 52 | /** 53 | * Constructs a new exception with the specified cause and a detail 54 | * message of (cause==null ? null : cause.toString()) (which 55 | * typically contains the class and detail message of cause). 56 | * This constructor is useful for exceptions that are little more than 57 | * wrappers for other throwables (for example, {@link 58 | * java.security.PrivilegedActionException}). 59 | * 60 | * @param cause the cause (which is saved for later retrieval by the 61 | * {@link #getCause()} method). (A null value is 62 | * permitted, and indicates that the cause is nonexistent or 63 | * unknown.) 64 | * @since 1.4 65 | */ 66 | public McuMgrException(Throwable cause) { 67 | super(cause); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /mcumgr-core/src/main/java/io/runtime/mcumgr/exception/McuMgrTimeoutException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 Runtime Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | package io.runtime.mcumgr.exception; 8 | 9 | import io.runtime.mcumgr.McuMgrErrorCode; 10 | import io.runtime.mcumgr.dfu.FirmwareUpgradeManager; 11 | 12 | /** 13 | * Used to convey errors caused by an {@link McuMgrErrorCode} within a response. This is used in 14 | * practice by {@link FirmwareUpgradeManager} to send a failure callback with the 15 | * {@link McuMgrErrorCode} that caused the failure. 16 | */ 17 | @SuppressWarnings("unused") 18 | public class McuMgrTimeoutException extends McuMgrException { 19 | } 20 | -------------------------------------------------------------------------------- /mcumgr-core/src/main/java/io/runtime/mcumgr/image/McuMgrImageVersion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Intellinium SAS, 2014-present 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | package io.runtime.mcumgr.image; 8 | 9 | import org.jetbrains.annotations.NotNull; 10 | 11 | import io.runtime.mcumgr.exception.McuMgrException; 12 | import io.runtime.mcumgr.util.ByteUtil; 13 | import io.runtime.mcumgr.util.Endian; 14 | 15 | /** 16 | * Represents a firmware image version for devices using McuBoot or the legacy Apache Mynewt 17 | * bootloader. 18 | *
19 | * For more info about McuBoot and image format see: 20 | * https://juullabs-oss.github.io/mcuboot/design.html 21 | */ 22 | @SuppressWarnings("unused") 23 | public class McuMgrImageVersion { 24 | 25 | private byte mMajor; 26 | private byte mMinor; 27 | private short mRevision; 28 | private int mBuildNum; 29 | 30 | private McuMgrImageVersion(byte major, byte minor, short revision, int buildNum) { 31 | mMajor = major; 32 | mMinor = minor; 33 | mRevision = revision; 34 | mBuildNum = buildNum; 35 | } 36 | 37 | @NotNull 38 | public static McuMgrImageVersion fromBytes(@NotNull byte[] b) throws McuMgrException { 39 | return fromBytes(b, 0); 40 | } 41 | 42 | @NotNull 43 | public static McuMgrImageVersion fromBytes(@NotNull byte[] b, int offset) throws McuMgrException { 44 | if (b.length - offset < getSize()) { 45 | throw new McuMgrException("The byte array is too short to be a McuMgrImageVersion"); 46 | } 47 | 48 | byte major = b[offset++]; 49 | byte minor = b[offset++]; 50 | short revision = (short) ByteUtil.byteArrayToUnsignedInt(b, offset, Endian.LITTLE, 2); 51 | int buildNum = ByteUtil.byteArrayToUnsignedInt(b, offset + 2, Endian.LITTLE, 4); 52 | 53 | return new McuMgrImageVersion(major, minor, revision, buildNum); 54 | } 55 | 56 | public static int getSize() { 57 | return 1 + 1 + 2 + 4; 58 | } 59 | 60 | public byte getMajor() { 61 | return mMajor; 62 | } 63 | 64 | public byte getMinor() { 65 | return mMinor; 66 | } 67 | 68 | public short getRevision() { 69 | return mRevision; 70 | } 71 | 72 | public int getBuildNum() { 73 | return mBuildNum; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /mcumgr-core/src/main/java/io/runtime/mcumgr/image/tlv/McuMgrImageTlvInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Intellinium SAS, 2014-present 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | package io.runtime.mcumgr.image.tlv; 8 | 9 | import io.runtime.mcumgr.exception.McuMgrException; 10 | import io.runtime.mcumgr.util.ByteUtil; 11 | import io.runtime.mcumgr.util.Endian; 12 | 13 | /** 14 | * Represents a type-length-value info table for firmware images using McuBoot or the legacy Apache 15 | * Mynewt bootloader. 16 | *
17 | * For more info about McuBoot and image format see: 18 | * https://juullabs-oss.github.io/mcuboot/design.html 19 | */ 20 | @SuppressWarnings("unused") 21 | public class McuMgrImageTlvInfo { 22 | private short mMagic; 23 | private short mTotal; 24 | 25 | private McuMgrImageTlvInfo() { 26 | // empty private constructor 27 | } 28 | 29 | public static McuMgrImageTlvInfo fromBytes(byte[] b) throws McuMgrException { 30 | return fromBytes(b, 0); 31 | } 32 | 33 | public static McuMgrImageTlvInfo fromBytes(byte[] b, int offset) throws McuMgrException { 34 | if (b.length - offset < getSize()) 35 | throw new McuMgrException("The byte array is too short to be a McuMgrImageTlvInfo: " + 36 | "length= " + b.length + ", offset= " + offset + ", min size= " + getSize()); 37 | 38 | McuMgrImageTlvInfo info = new McuMgrImageTlvInfo(); 39 | info.mMagic = (short) ByteUtil.byteArrayToUnsignedInt(b, offset, Endian.LITTLE, 2); 40 | info.mTotal = (short) ByteUtil.byteArrayToUnsignedInt(b, offset + 2, Endian.LITTLE, 2); 41 | 42 | if (info.mMagic != McuMgrImageTlv.IMG_TLV_INFO_MAGIC && 43 | info.mMagic != McuMgrImageTlv.IMG_TLV_PROTECTED_INFO_MAGIC) { 44 | throw new McuMgrException("Wrong magic number, magic=" + info.mMagic); 45 | } 46 | return info; 47 | } 48 | 49 | public static int getSize() { 50 | return 4; 51 | } 52 | 53 | public short getMagic() { 54 | return mMagic; 55 | } 56 | 57 | public short getTotal() { 58 | return mTotal; 59 | } 60 | 61 | public boolean isProtected() { 62 | return mMagic == McuMgrImageTlv.IMG_TLV_PROTECTED_INFO_MAGIC; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /mcumgr-core/src/main/java/io/runtime/mcumgr/image/tlv/McuMgrImageTlvTrailerEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 Runtime Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | package io.runtime.mcumgr.image.tlv; 8 | 9 | import java.util.Arrays; 10 | 11 | import io.runtime.mcumgr.exception.McuMgrException; 12 | import io.runtime.mcumgr.util.ByteUtil; 13 | import io.runtime.mcumgr.util.Endian; 14 | 15 | /** 16 | * Represents a type-length-value trailer entry for firmware images using McuBoot or the legacy 17 | * Apache Mynewt bootloader. 18 | *
19 | * For more info about McuBoot and image format see:
20 | * https://juullabs-oss.github.io/mcuboot/design.html
21 | */
22 | public class McuMgrImageTlvTrailerEntry {
23 | public final byte type;
24 | public final short length;
25 | public final byte[] value;
26 |
27 | private McuMgrImageTlvTrailerEntry(byte type, short length, byte[] value) {
28 | this.type = type;
29 | this.length = length;
30 | this.value = value;
31 | }
32 |
33 | public int getEntryLength() {
34 | return getMinSize() + length;
35 | }
36 |
37 | public static McuMgrImageTlvTrailerEntry fromBytes(byte[] b, int offset) throws McuMgrException {
38 | if (offset + getMinSize() > b.length) {
39 | throw new McuMgrException("The byte array is too short to be a McuMgrImageTlvTrailerEntry");
40 | }
41 | // Get type
42 | byte t = b[offset++];
43 | offset++; // Account for byte padding
44 | // Get length
45 | short l = (short) ByteUtil.byteArrayToUnsignedInt(b, offset, Endian.LITTLE, 2);
46 | offset += 2; // Move past length
47 | // Get value
48 | byte[] v = Arrays.copyOfRange(b, offset, offset + l);
49 | return new McuMgrImageTlvTrailerEntry(t, l, v);
50 | }
51 |
52 | public static int getMinSize() {
53 | return 4;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/mcumgr-core/src/main/java/io/runtime/mcumgr/managers/CrashManager.java:
--------------------------------------------------------------------------------
1 | package io.runtime.mcumgr.managers;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 |
5 | import java.util.HashMap;
6 |
7 | import io.runtime.mcumgr.McuManager;
8 | import io.runtime.mcumgr.McuMgrCallback;
9 | import io.runtime.mcumgr.McuMgrTransport;
10 | import io.runtime.mcumgr.exception.McuMgrException;
11 | import io.runtime.mcumgr.response.McuMgrResponse;
12 | import io.runtime.mcumgr.response.config.McuMgrConfigReadResponse;
13 |
14 | @SuppressWarnings({"unused", "WeakerAccess"})
15 | public class CrashManager extends McuManager {
16 |
17 | /**
18 | * Crash test command ID.
19 | */
20 | private final static int ID_CRASH_TEST = 0;
21 |
22 | /**
23 | * Type of crash to test on the device.
24 | */
25 | public enum Test {
26 | DIV_0("div0"),
27 | JUMP_0("jump0"),
28 | REF_0("ref0"),
29 | ASSERT("assert"),
30 | WDOG("wdog");
31 | private final String value;
32 | Test(String value) {
33 | this.value = value;
34 | }
35 | @Override
36 | public String toString() {
37 | return value;
38 | }
39 | }
40 |
41 | /**
42 | * Construct a McuManager instance.
43 | *
44 | * @param transporter the transporter to use to send commands.
45 | */
46 | public CrashManager(@NotNull McuMgrTransport transporter) {
47 | super(McuManager.GROUP_CRASH, transporter);
48 | }
49 |
50 | /**
51 | * Trigger a crash test.
52 | * @param test The type of crash test.
53 | * @return The response
54 | * @throws McuMgrException on failure.
55 | */
56 | @NotNull
57 | public McuMgrResponse test(@NotNull Test test) throws McuMgrException {
58 | HashMapyyyy-MM-dd'T'HH:mm:ss.SSSSSS
format.
17 | */
18 | @JsonProperty("datetime")
19 | public String datetime;
20 |
21 | @JsonCreator
22 | public McuMgrReadDateTimeResponse() {}
23 | }
24 |
--------------------------------------------------------------------------------
/mcumgr-core/src/main/java/io/runtime/mcumgr/response/fs/McuMgrFsDownloadResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017-2018 Runtime Inc.
3 | * Copyright (c) Intellinium SAS, 2014-present
4 | *
5 | * SPDX-License-Identifier: Apache-2.0
6 | */
7 |
8 | package io.runtime.mcumgr.response.fs;
9 |
10 | import com.fasterxml.jackson.annotation.JsonCreator;
11 | import com.fasterxml.jackson.annotation.JsonProperty;
12 |
13 | import io.runtime.mcumgr.response.DownloadResponse;
14 | import io.runtime.mcumgr.response.McuMgrResponse;
15 |
16 | public class McuMgrFsDownloadResponse extends DownloadResponse {
17 | @JsonCreator
18 | public McuMgrFsDownloadResponse() {}
19 | }
20 |
--------------------------------------------------------------------------------
/mcumgr-core/src/main/java/io/runtime/mcumgr/response/fs/McuMgrFsUploadResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017-2018 Runtime Inc.
3 | * Copyright (c) Intellinium SAS, 2014-present
4 | *
5 | * SPDX-License-Identifier: Apache-2.0
6 | */
7 |
8 | package io.runtime.mcumgr.response.fs;
9 |
10 | import com.fasterxml.jackson.annotation.JsonCreator;
11 | import com.fasterxml.jackson.annotation.JsonProperty;
12 |
13 | import io.runtime.mcumgr.response.McuMgrResponse;
14 | import io.runtime.mcumgr.response.UploadResponse;
15 |
16 | public class McuMgrFsUploadResponse extends UploadResponse {
17 | @JsonCreator
18 | public McuMgrFsUploadResponse() {}
19 | }
20 |
--------------------------------------------------------------------------------
/mcumgr-core/src/main/java/io/runtime/mcumgr/response/img/McuMgrCoreLoadResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, Nordic Semiconductor
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6 | *
7 | * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 | *
9 | * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
10 | * documentation and/or other materials provided with the distribution.
11 | *
12 | * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
13 | * software without specific prior written permission.
14 | *
15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
17 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
18 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
20 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 | */
22 |
23 | package io.runtime.mcumgr.response.img;
24 |
25 | import com.fasterxml.jackson.annotation.JsonCreator;
26 | import com.fasterxml.jackson.annotation.JsonProperty;
27 |
28 | import io.runtime.mcumgr.response.DownloadResponse;
29 | import io.runtime.mcumgr.response.McuMgrResponse;
30 |
31 | public class McuMgrCoreLoadResponse extends DownloadResponse {
32 | @JsonCreator
33 | public McuMgrCoreLoadResponse() {}
34 | }
35 |
--------------------------------------------------------------------------------
/mcumgr-core/src/main/java/io/runtime/mcumgr/response/img/McuMgrImageStateResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Intellinium SAS, 2014-present
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 | package io.runtime.mcumgr.response.img;
7 |
8 | import com.fasterxml.jackson.annotation.JsonCreator;
9 | import com.fasterxml.jackson.annotation.JsonProperty;
10 |
11 | import io.runtime.mcumgr.response.McuMgrResponse;
12 |
13 | @SuppressWarnings("unused")
14 | public class McuMgrImageStateResponse extends McuMgrResponse {
15 | // For Mynewt see:
16 | // https://github.com/apache/mynewt-core/blob/master/boot/split/include/split/split.h
17 | public static final int SPLIT_STATUS_INVALID = 0;
18 | public static final int SPLIT_STATUS_NOT_MATCHING = 1;
19 | public static final int SPLIT_STATUS_MATCHING = 2;
20 |
21 | /** Image slot information. */
22 | @JsonProperty("images")
23 | public ImageSlot[] images;
24 | /**
25 | * The split status. For Zephyr implementation this is always 0.
26 | * For Mynewt, see SPLIT_STATUS_* constants.
27 | */
28 | @JsonProperty("splitStatus")
29 | public int splitStatus;
30 |
31 | @JsonCreator
32 | public McuMgrImageStateResponse() {}
33 |
34 | /**
35 | * The single image slot data structure.
36 | */
37 | public static class ImageSlot {
38 | /** The slot number: 0 or 1. */
39 | @JsonProperty("slot")
40 | public int slot;
41 | /** The image version string. */
42 | @JsonProperty("version")
43 | public String version;
44 | /** The image hash. */
45 | @JsonProperty("hash")
46 | public byte[] hash;
47 | /** An image is bootable when the Boot Loader verified that the image is valid. */
48 | @JsonProperty("bootable")
49 | public boolean bootable;
50 | /**
51 | * An image is pending when it was scheduled to be swapped to slot 0.
52 | * That is, after the test or confirm commands were sent, but before
53 | * the device was reset.
54 | */
55 | @JsonProperty("pending")
56 | public boolean pending;
57 | /** An image is confirmed when it managed to boot on slot 0. */
58 | @JsonProperty("confirmed")
59 | public boolean confirmed;
60 | /** An image is active when it is running on slot 0. */
61 | @JsonProperty("active")
62 | public boolean active;
63 | /** An image is permanent after it was confirmed using confirm command. */
64 | @JsonProperty("permanent")
65 | public boolean permanent;
66 |
67 | @JsonCreator
68 | public ImageSlot() {}
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/mcumgr-core/src/main/java/io/runtime/mcumgr/response/img/McuMgrImageUploadResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Intellinium SAS, 2014-present
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | package io.runtime.mcumgr.response.img;
8 |
9 | import com.fasterxml.jackson.annotation.JsonCreator;
10 | import com.fasterxml.jackson.annotation.JsonProperty;
11 |
12 | import io.runtime.mcumgr.response.McuMgrResponse;
13 | import io.runtime.mcumgr.response.UploadResponse;
14 |
15 | public class McuMgrImageUploadResponse extends UploadResponse {
16 | @JsonCreator
17 | public McuMgrImageUploadResponse() {}
18 | }
19 |
--------------------------------------------------------------------------------
/mcumgr-core/src/main/java/io/runtime/mcumgr/response/log/McuMgrLevelListResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Intellinium SAS, 2014-present
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | package io.runtime.mcumgr.response.log;
8 |
9 |
10 | import com.fasterxml.jackson.annotation.JsonCreator;
11 | import com.fasterxml.jackson.annotation.JsonProperty;
12 |
13 | import io.runtime.mcumgr.response.McuMgrResponse;
14 |
15 | public class McuMgrLevelListResponse extends McuMgrResponse {
16 | @JsonProperty("level_map")
17 | public String[] level_map;
18 |
19 | @JsonCreator
20 | public McuMgrLevelListResponse() {}
21 | }
22 |
--------------------------------------------------------------------------------
/mcumgr-core/src/main/java/io/runtime/mcumgr/response/log/McuMgrLogListResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Intellinium SAS, 2014-present
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | package io.runtime.mcumgr.response.log;
8 |
9 | import com.fasterxml.jackson.annotation.JsonCreator;
10 | import com.fasterxml.jackson.annotation.JsonProperty;
11 |
12 | import io.runtime.mcumgr.response.McuMgrResponse;
13 |
14 | public class McuMgrLogListResponse extends McuMgrResponse {
15 | @JsonProperty("log_list")
16 | public String[] log_list;
17 |
18 | @JsonCreator
19 | public McuMgrLogListResponse() {}
20 | }
21 |
--------------------------------------------------------------------------------
/mcumgr-core/src/main/java/io/runtime/mcumgr/response/log/McuMgrModuleListResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Intellinium SAS, 2014-present
3 | *
4 | * SPDX-License-Identifier: Apache-2.0
5 | */
6 |
7 | package io.runtime.mcumgr.response.log;
8 |
9 | import com.fasterxml.jackson.annotation.JsonCreator;
10 | import com.fasterxml.jackson.annotation.JsonProperty;
11 |
12 | import java.util.Map;
13 |
14 | import io.runtime.mcumgr.response.McuMgrResponse;
15 |
16 | public class McuMgrModuleListResponse extends McuMgrResponse {
17 | @JsonProperty("module_map")
18 | public Map