MYNEWT-519 img_mgmt - Indicate "permanent" flag.

Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/61acaddf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/61acaddf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/61acaddf

Branch: refs/heads/develop
Commit: 61acaddfdcc4be8b181efd6a7a6e68a33e08b71b
Parents: ba34db6
Author: Christopher Collins <[email protected]>
Authored: Wed Dec 21 13:47:56 2016 -0800
Committer: Christopher Collins <[email protected]>
Committed: Wed Dec 21 13:47:56 2016 -0800

----------------------------------------------------------------------
 mgmt/imgmgr/include/imgmgr/imgmgr.h |  1 +
 mgmt/imgmgr/src/imgmgr_state.c      | 12 ++++++++++++
 2 files changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/61acaddf/mgmt/imgmgr/include/imgmgr/imgmgr.h
----------------------------------------------------------------------
diff --git a/mgmt/imgmgr/include/imgmgr/imgmgr.h 
b/mgmt/imgmgr/include/imgmgr/imgmgr.h
index 6494283..8f95cf0 100644
--- a/mgmt/imgmgr/include/imgmgr/imgmgr.h
+++ b/mgmt/imgmgr/include/imgmgr/imgmgr.h
@@ -41,6 +41,7 @@ extern "C" {
 #define IMGMGR_STATE_F_PENDING          0x01
 #define IMGMGR_STATE_F_CONFIRMED        0x02
 #define IMGMGR_STATE_F_ACTIVE           0x04
+#define IMGMGR_STATE_F_PERMANENT        0x08
 
 extern int boot_current_slot;
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/61acaddf/mgmt/imgmgr/src/imgmgr_state.c
----------------------------------------------------------------------
diff --git a/mgmt/imgmgr/src/imgmgr_state.c b/mgmt/imgmgr/src/imgmgr_state.c
index 739145e..c2beda8 100644
--- a/mgmt/imgmgr/src/imgmgr_state.c
+++ b/mgmt/imgmgr/src/imgmgr_state.c
@@ -59,6 +59,14 @@ imgmgr_state_flags(int query_slot)
         }
         break;
 
+    case BOOT_SWAP_TYPE_PERM:
+        if (query_slot == 0) {
+            flags |= IMGMGR_STATE_F_CONFIRMED;
+        } else if (query_slot == 1) {
+            flags |= IMGMGR_STATE_F_PENDING | IMGMGR_STATE_F_PERMANENT;
+        }
+        break;
+
     case BOOT_SWAP_TYPE_REVERT:
         if (query_slot == 0) {
             flags |= IMGMGR_STATE_F_ACTIVE;
@@ -276,6 +284,10 @@ imgmgr_state_read(struct mgmt_cbuf *cb)
         g_err |= cbor_encode_boolean(&image,
                                      state_flags & IMGMGR_STATE_F_ACTIVE);
 
+        g_err |= cbor_encode_text_stringz(&image, "permanent");
+        g_err |= cbor_encode_boolean(&image,
+                                     state_flags & IMGMGR_STATE_F_PERMANENT);
+
         g_err |= cbor_encoder_close_container(&images, &image);
     }
 

Reply via email to