1 /* 2 * Copyright (c) 2018-2021 mcumgr authors 3 * Copyright (c) 2022-2023 Nordic Semiconductor ASA 4 * 5 * SPDX-License-Identifier: Apache-2.0 6 */ 7 8 #ifndef H_MGMT_MGMT_DEFINES_ 9 #define H_MGMT_MGMT_DEFINES_ 10 11 #include <inttypes.h> 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 /** 18 * @brief MCUmgr mgmt API 19 * @defgroup mcumgr_mgmt_api MCUmgr mgmt API 20 * @ingroup mcumgr 21 * @{ 22 */ 23 24 /** 25 * Used at end of MCUmgr handlers to return an error if the message size limit was reached, 26 * or OK if it was not 27 */ 28 #define MGMT_RETURN_CHECK(ok) ok ? MGMT_ERR_EOK : MGMT_ERR_EMSGSIZE 29 30 /** Opcodes; encoded in first byte of header. */ 31 enum mcumgr_op_t { 32 /** Read op-code */ 33 MGMT_OP_READ = 0, 34 35 /** Read response op-code */ 36 MGMT_OP_READ_RSP, 37 38 /** Write op-code */ 39 MGMT_OP_WRITE, 40 41 /** Write response op-code */ 42 MGMT_OP_WRITE_RSP, 43 }; 44 45 /** 46 * MCUmgr groups. The first 64 groups are reserved for system level mcumgr 47 * commands. Per-user commands are then defined after group 64. 48 */ 49 enum mcumgr_group_t { 50 /** OS (operating system) group */ 51 MGMT_GROUP_ID_OS = 0, 52 53 /** Image management group, used for uploading firmware images */ 54 MGMT_GROUP_ID_IMAGE, 55 56 /** Statistic management group, used for retieving statistics */ 57 MGMT_GROUP_ID_STAT, 58 59 /** Settings management (config) group, used for reading/writing settings */ 60 MGMT_GROUP_ID_SETTINGS, 61 62 /** Log management group (unused) */ 63 MGMT_GROUP_ID_LOG, 64 65 /** Crash group (unused) */ 66 MGMT_GROUP_ID_CRASH, 67 68 /** Split image management group (unused) */ 69 MGMT_GROUP_ID_SPLIT, 70 71 /** Run group (unused) */ 72 MGMT_GROUP_ID_RUN, 73 74 /** FS (file system) group, used for performing file IO operations */ 75 MGMT_GROUP_ID_FS, 76 77 /** Shell management group, used for executing shell commands */ 78 MGMT_GROUP_ID_SHELL, 79 80 /** User groups defined from 64 onwards */ 81 MGMT_GROUP_ID_PERUSER = 64, 82 83 /** Zephyr-specific groups decrease from PERUSER to avoid collision with upstream and 84 * user-defined groups. 85 * Zephyr-specific: Basic group 86 */ 87 ZEPHYR_MGMT_GRP_BASIC = (MGMT_GROUP_ID_PERUSER - 1), 88 }; 89 90 /** 91 * MCUmgr error codes. 92 */ 93 enum mcumgr_err_t { 94 /** No error (success). */ 95 MGMT_ERR_EOK = 0, 96 97 /** Unknown error. */ 98 MGMT_ERR_EUNKNOWN, 99 100 /** Insufficient memory (likely not enough space for CBOR object). */ 101 MGMT_ERR_ENOMEM, 102 103 /** Error in input value. */ 104 MGMT_ERR_EINVAL, 105 106 /** Operation timed out. */ 107 MGMT_ERR_ETIMEOUT, 108 109 /** No such file/entry. */ 110 MGMT_ERR_ENOENT, 111 112 /** Current state disallows command. */ 113 MGMT_ERR_EBADSTATE, 114 115 /** Response too large. */ 116 MGMT_ERR_EMSGSIZE, 117 118 /** Command not supported. */ 119 MGMT_ERR_ENOTSUP, 120 121 /** Corrupt */ 122 MGMT_ERR_ECORRUPT, 123 124 /** Command blocked by processing of other command */ 125 MGMT_ERR_EBUSY, 126 127 /** Access to specific function, command or resource denied */ 128 MGMT_ERR_EACCESSDENIED, 129 130 /** Requested SMP MCUmgr protocol version is not supported (too old) */ 131 MGMT_ERR_UNSUPPORTED_TOO_OLD, 132 133 /** Requested SMP MCUmgr protocol version is not supported (too new) */ 134 MGMT_ERR_UNSUPPORTED_TOO_NEW, 135 136 /** User errors defined from 256 onwards */ 137 MGMT_ERR_EPERUSER = 256 138 }; 139 140 #define MGMT_HDR_SIZE 8 141 142 /** 143 * @} 144 */ 145 146 #ifdef __cplusplus 147 } 148 #endif 149 150 #endif /* MGMT_MGMT_DEFINES_H_ */ 151