summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/backend/hal-board-interface.h3
-rw-r--r--include/hal-board.h22
-rw-r--r--src/board.c32
3 files changed, 57 insertions, 0 deletions
diff --git a/include/backend/hal-board-interface.h b/include/backend/hal-board-interface.h
index 9d9e708..619ee0b 100644
--- a/include/backend/hal-board-interface.h
+++ b/include/backend/hal-board-interface.h
@@ -45,6 +45,9 @@ typedef struct _hal_backend_board_funcs {
int (*set_upgrade_state)(char *state);
int (*get_upgrade_state)(char *buffer, const int max_len);
+
+ int (*set_upgrade_type)(char *type);
+ int (*get_upgrade_type)(char *buffer, const int max_len);
} hal_backend_board_funcs;
#ifdef __cplusplus
diff --git a/include/hal-board.h b/include/hal-board.h
index aec56e4..5377a46 100644
--- a/include/hal-board.h
+++ b/include/hal-board.h
@@ -210,6 +210,28 @@ int hal_device_board_set_upgrade_state(char *state_from, char *state_to);
*/
int hal_device_board_get_upgrade_state(char *buffer, const int max_len);
+/**
+ * @brief Get upgrade type
+ *
+ * @param[out] buffer Upgrade type
+ * @param[in] max_len Buffer size
+ *
+ * At most (max_len - 1) bytes of the state string will be copied to the buffer argument,
+ * and NULL is finally appended at the end of the string.
+ *
+ * @return 0 on success, otherwise a negative error value
+ */
+int hal_device_board_get_upgrade_type(char *buffer, const int max_len);
+
+/**
+ * @brief Set upgrade type
+ *
+ * @param[in] type Upgrade type
+ *
+ * @return 0 on success, otherwise a negative error value
+ */
+int hal_device_board_set_upgrade_type(char *type);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/board.c b/src/board.c
index c45e444..9966d8d 100644
--- a/src/board.c
+++ b/src/board.c
@@ -415,3 +415,35 @@ int hal_device_board_get_upgrade_state(char *buffer, const int max_len)
return hal_board_funcs->get_upgrade_state(buffer, max_len);
}
+
+int hal_device_board_set_upgrade_type(char *type)
+{
+ int ret;
+
+ if (!hal_board_funcs) {
+ if ((ret = hal_device_board_get_backend()) < 0)
+ return ret;
+ }
+
+ if (!hal_board_funcs ||
+ !hal_board_funcs->set_upgrade_type)
+ return -ENODEV;
+
+ return hal_board_funcs->set_upgrade_type(type);
+}
+
+int hal_device_board_get_upgrade_type(char *buffer, const int max_len)
+{
+ int ret;
+
+ if (!hal_board_funcs) {
+ if ((ret = hal_device_board_get_backend()) < 0)
+ return ret;
+ }
+
+ if (!hal_board_funcs ||
+ !hal_board_funcs->get_upgrade_type)
+ return -ENODEV;
+
+ return hal_board_funcs->get_upgrade_type(buffer, max_len);
+}