From 14034106fc7da34c3b11fca1b3b92c49eb034acc Mon Sep 17 00:00:00 2001 From: Tennessee Carmel-Veilleux Date: Tue, 11 Oct 2022 22:36:37 -0400 Subject: [PATCH] Introduce a CHIP_ERROR table (#23131) * Introduce a CHIP_ERROR table - Constantly looking-up the code to find CHIP_ERROR values (especially the ones with embedded errors outside of 0x00.0xFF range) is painstaking. This PR: - Adds a script to generate a list of CHIP_ERROR errors codes in decimal and hex. - Generated the `docs/ERROR_CODES.md` file Testing done: - Audited the output visually - No functional change to SDK * Restyle --- docs/ERROR_CODES.md | 349 +++++++++++++++++++++++++++++++++++++++++ scripts/error_table.py | 151 ++++++++++++++++++ 2 files changed, 500 insertions(+) create mode 100644 docs/ERROR_CODES.md create mode 100644 scripts/error_table.py diff --git a/docs/ERROR_CODES.md b/docs/ERROR_CODES.md new file mode 100644 index 00000000000000..7415d292ce1e26 --- /dev/null +++ b/docs/ERROR_CODES.md @@ -0,0 +1,349 @@ +# Matter SDK `CHIP_ERROR` enums values + +This file was **AUTOMATICALLY** generated by +`python scripts/error_table.py > docs/ERROR_CODES.md`. DO NOT EDIT BY HAND! + +## Table of contents + +- [SDK Core errors: range `0x000..0x0FF`](#sdk-core-errors) +- [SDK Inet Layer errors: range `0x100..0x1FF`](#sdk-inet-layer-errors) +- [SDK Device Layer errors: range `0x200..0x2FF`](#sdk-device-layer-errors) +- [ASN.1 Layer errors: range `0x300..0x3FF`](#asn-1-layer-errors) +- [BLE Layer errors: range `0x400..0x4FF`](#ble-layer-errors) +- [IM Global errors errors: range `0x500..0x5FF`](#im-global-errors-errors) + +## SDK Core errors + +| Decimal | Hex | Name | Description | +| ------- | ---- | ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| 0 | 0x00 | `CHIP_NO_ERROR` | This defines the CHIP error code for success or no error | +| 1 | 0x01 | `CHIP_ERROR_SENDING_BLOCKED` | A message exceeds the sent limit | +| 2 | 0x02 | `CHIP_ERROR_CONNECTION_ABORTED` | A connection has been aborted | +| 3 | 0x03 | `CHIP_ERROR_INCORRECT_STATE` | An unexpected state was encountered | +| 4 | 0x04 | `CHIP_ERROR_MESSAGE_TOO_LONG` | A message is too long | +| 5 | 0x05 | `CHIP_ERROR_UNSUPPORTED_EXCHANGE_VERSION` | An exchange version is not supported | +| 6 | 0x06 | `CHIP_ERROR_TOO_MANY_UNSOLICITED_MESSAGE_HANDLERS` | The attempt to register an unsolicited message handler failed because the unsolicited message handler pool is full | +| 7 | 0x07 | `CHIP_ERROR_NO_UNSOLICITED_MESSAGE_HANDLER` | The attempt to unregister an unsolicited message handler failed because the target handler was not found in the unsolicited message handler pool | +| 8 | 0x08 | `CHIP_ERROR_NO_CONNECTION_HANDLER` | No callback has been registered for handling a connection | +| 9 | 0x09 | `CHIP_ERROR_TOO_MANY_PEER_NODES` | The number of peer nodes exceeds the maximum limit of a local node | +| 10 | 0x0A | `CHIP_ERROR_SENTINEL` | For use locally to mark conditions such as value found or end of iteration | +| 11 | 0x0B | `CHIP_ERROR_NO_MEMORY` | The attempt to allocate a buffer or object failed due to a lack of memory | +| 12 | 0x0C | `CHIP_ERROR_NO_MESSAGE_HANDLER` | No callback has been registered for handling a message | +| 13 | 0x0D | `CHIP_ERROR_MESSAGE_INCOMPLETE` | A message is incomplete | +| 14 | 0x0E | `CHIP_ERROR_DATA_NOT_ALIGNED` | The data is not aligned | +| 15 | 0x0F | `CHIP_ERROR_UNKNOWN_KEY_TYPE` | The encryption key type is unknown | +| 16 | 0x10 | `CHIP_ERROR_KEY_NOT_FOUND` | The encryption key is not found | +| 17 | 0x11 | `CHIP_ERROR_WRONG_ENCRYPTION_TYPE` | The encryption type is incorrect for the specified key | +| 18 | 0x12 | `CHIP_ERROR_TOO_MANY_KEYS` | The attempt to allocate a key failed because the number of active keys exceeds the maximum limit | +| 19 | 0x13 | `CHIP_ERROR_INTEGRITY_CHECK_FAILED` | The integrity check in the message does not match the expected integrity check | +| 20 | 0x14 | `CHIP_ERROR_INVALID_SIGNATURE` | Invalid signature | +| 21 | 0x15 | `CHIP_ERROR_UNSUPPORTED_MESSAGE_VERSION` | A message version is unsupported | +| 22 | 0x16 | `CHIP_ERROR_UNSUPPORTED_ENCRYPTION_TYPE` | An encryption type is unsupported | +| 23 | 0x17 | `CHIP_ERROR_UNSUPPORTED_SIGNATURE_TYPE` | A signature type is unsupported | +| 24 | 0x18 | `CHIP_ERROR_INVALID_MESSAGE_LENGTH` | A message length is invalid | +| 25 | 0x19 | `CHIP_ERROR_BUFFER_TOO_SMALL` | A buffer is too small | +| 26 | 0x1A | `CHIP_ERROR_DUPLICATE_KEY_ID` | A key id is duplicate | +| 27 | 0x1B | `CHIP_ERROR_WRONG_KEY_TYPE` | A key type does not match the expected key type | +| 28 | 0x1C | `CHIP_ERROR_WELL_UNINITIALIZED` | A requested object is uninitialized | +| 29 | 0x1D | `CHIP_ERROR_WELL_EMPTY` | A requested object is empty | +| 30 | 0x1E | `CHIP_ERROR_INVALID_STRING_LENGTH` | A string length is invalid | +| 31 | 0x1F | `CHIP_ERROR_INVALID_LIST_LENGTH` | A list length is invalid | +| 32 | 0x20 | `CHIP_ERROR_INVALID_INTEGRITY_TYPE` | An integrity type is invalid | +| 33 | 0x21 | `CHIP_ERROR_END_OF_TLV` | The end of a TLV encoding, or the end of a TLV container element has been reached | +| 34 | 0x22 | `CHIP_ERROR_TLV_UNDERRUN` | The TLV encoding ended prematurely | +| 35 | 0x23 | `CHIP_ERROR_INVALID_TLV_ELEMENT` | A TLV element is invalid | +| 36 | 0x24 | `CHIP_ERROR_INVALID_TLV_TAG` | A TLV tag is invalid | +| 37 | 0x25 | `CHIP_ERROR_UNKNOWN_IMPLICIT_TLV_TAG` | An implicitly encoded TLV tag was encountered, but an implicit profile id has not been defined | +| 38 | 0x26 | `CHIP_ERROR_WRONG_TLV_TYPE` | A TLV type is wrong | +| 39 | 0x27 | `CHIP_ERROR_TLV_CONTAINER_OPEN` | A TLV container is unexpectedly open | +| 40 | 0x28 | `CHIP_ERROR_INVALID_TRANSFER_MODE` | A transfer mode is invalid | +| 41 | 0x29 | `CHIP_ERROR_INVALID_PROFILE_ID` | A profile id is invalid | +| 42 | 0x2A | `CHIP_ERROR_INVALID_MESSAGE_TYPE` | A message type is invalid | +| 43 | 0x2B | `CHIP_ERROR_UNEXPECTED_TLV_ELEMENT` | An unexpected TLV element was encountered | +| 44 | 0x2C | `CHIP_ERROR_STATUS_REPORT_RECEIVED` | A status report is received from a peer node | +| 45 | 0x2D | `CHIP_ERROR_NOT_IMPLEMENTED` | A requested function or feature is not implemented | +| 46 | 0x2E | `CHIP_ERROR_INVALID_ADDRESS` | An address is invalid | +| 47 | 0x2F | `CHIP_ERROR_INVALID_ARGUMENT` | An argument is invalid | +| 48 | 0x30 | `CHIP_ERROR_INVALID_PATH_LIST` | A TLV path list is invalid | +| 49 | 0x31 | `CHIP_ERROR_INVALID_DATA_LIST` | A TLV data list is invalid | +| 50 | 0x32 | `CHIP_ERROR_TIMEOUT` | A request timed out | +| 51 | 0x33 | `CHIP_ERROR_INVALID_DEVICE_DESCRIPTOR` | A device descriptor is invalid | +| 52 | 0x34 | `CHIP_ERROR_UNSUPPORTED_DEVICE_DESCRIPTOR_VERSION` | A device descriptor version is unsupported | +| 53 | 0x35 | `CHIP_ERROR_END_OF_INPUT` | An input ended | +| 54 | 0x36 | `CHIP_ERROR_RATE_LIMIT_EXCEEDED` | A rate limit is exceeded | +| 55 | 0x37 | `CHIP_ERROR_SECURITY_MANAGER_BUSY` | A security manager is busy | +| 56 | 0x38 | `CHIP_ERROR_INVALID_PASE_PARAMETER` | A PASE parameter is invalid | +| 57 | 0x39 | `CHIP_ERROR_PASE_SUPPORTS_ONLY_CONFIG1` | PASE supports only config1 | +| 58 | 0x3A | `CHIP_ERROR_KEY_CONFIRMATION_FAILED` | A key confirmation failed | +| 59 | 0x3B | `CHIP_ERROR_INVALID_USE_OF_SESSION_KEY` | A use of session key is invalid | +| 60 | 0x3C | `CHIP_ERROR_CONNECTION_CLOSED_UNEXPECTEDLY` | A connection is closed unexpectedly | +| 61 | 0x3D | `CHIP_ERROR_MISSING_TLV_ELEMENT` | A TLV element is missing | +| 62 | 0x3E | `CHIP_ERROR_RANDOM_DATA_UNAVAILABLE` | Secure random data is not available | +| 63 | 0x3F | `CHIP_ERROR_UNSUPPORTED_HOST_PORT_ELEMENT` | A type in host/port list is unsupported | +| 64 | 0x40 | `CHIP_ERROR_INVALID_HOST_SUFFIX_INDEX` | A suffix index in host/port list is invalid | +| 65 | 0x41 | `CHIP_ERROR_HOST_PORT_LIST_EMPTY` | A host/port list is empty | +| 66 | 0x42 | `CHIP_ERROR_UNSUPPORTED_AUTH_MODE` | An authentication mode is unsupported | +| 67 | 0x43 | `CHIP_ERROR_INVALID_SERVICE_EP` | A service endpoint is invalid | +| 68 | 0x44 | `CHIP_ERROR_INVALID_DIRECTORY_ENTRY_TYPE` | A directory entry type is unknown | +| 69 | 0x45 | `CHIP_ERROR_FORCED_RESET` | A service manager is forced to reset | +| 70 | 0x46 | `CHIP_ERROR_NO_ENDPOINT` | No endpoint is available | +| 71 | 0x47 | `CHIP_ERROR_INVALID_DESTINATION_NODE_ID` | A destination node id is invalid | +| 72 | 0x48 | `CHIP_ERROR_NOT_CONNECTED` | The operation cannot be performed because the underlying object is not connected | +| 73 | 0x49 | `CHIP_ERROR_NO_SW_UPDATE_AVAILABLE` | No software update is available | +| 74 | 0x4A | `CHIP_ERROR_CA_CERT_NOT_FOUND` | CA certificate is not found | +| 75 | 0x4B | `CHIP_ERROR_CERT_PATH_LEN_CONSTRAINT_EXCEEDED` | A certificate path length exceeds the constraint | +| 76 | 0x4C | `CHIP_ERROR_CERT_PATH_TOO_LONG` | A certificate path is too long | +| 77 | 0x4D | `CHIP_ERROR_CERT_USAGE_NOT_ALLOWED` | A requested certificate usage is not allowed | +| 78 | 0x4E | `CHIP_ERROR_CERT_EXPIRED` | A certificate expired | +| 79 | 0x4F | `CHIP_ERROR_CERT_NOT_VALID_YET` | A certificate is not valid yet | +| 80 | 0x50 | `CHIP_ERROR_UNSUPPORTED_CERT_FORMAT` | A certificate format is unsupported | +| 81 | 0x51 | `CHIP_ERROR_UNSUPPORTED_ELLIPTIC_CURVE` | An elliptic curve is unsupported | +| 82 | 0x52 | `CHIP_ERROR_CERT_NOT_USED` | A certificate was not used during the chain validation | +| 83 | 0x53 | `CHIP_ERROR_CERT_NOT_FOUND` | A certificate is not found | +| 84 | 0x54 | `CHIP_ERROR_INVALID_CASE_PARAMETER` | A CASE parameter is invalid | +| 85 | 0x55 | `CHIP_ERROR_UNSUPPORTED_CASE_CONFIGURATION` | A CASE configuration is unsupported | +| 86 | 0x56 | `CHIP_ERROR_CERT_LOAD_FAILED` | A certificate load failed | +| 87 | 0x57 | `CHIP_ERROR_CERT_NOT_TRUSTED` | A certificate is not trusted | +| 88 | 0x58 | `CHIP_ERROR_INVALID_ACCESS_TOKEN` | An access token is invalid | +| 89 | 0x59 | `CHIP_ERROR_WRONG_CERT_DN` | A certificate subject/issuer distinguished name is wrong | +| 90 | 0x5A | `CHIP_ERROR_INVALID_PROVISIONING_BUNDLE` | A provisioning bundle is invalid | +| 91 | 0x5B | `CHIP_ERROR_PROVISIONING_BUNDLE_DECRYPTION_ERROR` | A provision bundle encountered a decryption error | +| 92 | 0x5C | `CHIP_ERROR_WRONG_NODE_ID` | A node id is wrong | +| 93 | 0x5D | `CHIP_ERROR_CONN_ACCEPTED_ON_WRONG_PORT` | A connection is accepted on a wrong port | +| 94 | 0x5E | `CHIP_ERROR_CALLBACK_REPLACED` | An application callback has been replaced | +| 95 | 0x5F | `CHIP_ERROR_NO_CASE_AUTH_DELEGATE` | No CASE authentication delegate is set | +| 96 | 0x60 | `CHIP_ERROR_DEVICE_LOCATE_TIMEOUT` | The attempt to locate device timed out | +| 97 | 0x61 | `CHIP_ERROR_DEVICE_CONNECT_TIMEOUT` | The attempt to connect device timed out | +| 98 | 0x62 | `CHIP_ERROR_DEVICE_AUTH_TIMEOUT` | The attempt to authenticate device timed out | +| 99 | 0x63 | `CHIP_ERROR_MESSAGE_NOT_ACKNOWLEDGED` | A message is not acknowledged after max retries | +| 100 | 0x64 | `CHIP_ERROR_RETRANS_TABLE_FULL` | A retransmission table is already full | +| 101 | 0x65 | `CHIP_ERROR_INVALID_ACK_MESSAGE_COUNTER` | An acknowledgment id is invalid | +| 102 | 0x66 | `CHIP_ERROR_SEND_THROTTLED` | A send is throttled | +| 103 | 0x67 | `CHIP_ERROR_WRONG_MSG_VERSION_FOR_EXCHANGE` | A message version is not supported by the current exchange context | +| 104 | 0x68 | `CHIP_ERROR_TRANSACTION_CANCELED` | A transaction is cancelled | +| 105 | 0x69 | `CHIP_ERROR_LISTENER_ALREADY_STARTED` | A listener has already started | +| 106 | 0x6A | `CHIP_ERROR_LISTENER_ALREADY_STOPPED` | A listener has already stopped | +| 107 | 0x6B | `CHIP_ERROR_INVALID_SUBSCRIPTION` | A message was received as part of a subscription exchange that has a mis-matching subscription id | +| 108 | 0x6C | `CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE` | A CHIP feature is unsupported | +| 109 | 0x6D | `CHIP_ERROR_PASE_RECONFIGURE_REQUIRED` | PASE is required to reconfigure | +| 110 | 0x6E | `CHIP_ERROR_INVALID_PASE_CONFIGURATION` | A PASE configuration is invalid | +| 111 | 0x6F | `CHIP_ERROR_NO_COMMON_PASE_CONFIGURATIONS` | No PASE configuration is in common | +| 112 | 0x70 | `CHIP_ERROR_UNSOLICITED_MSG_NO_ORIGINATOR` | An unsolicited message with the originator bit clear | +| 113 | 0x71 | `CHIP_ERROR_INVALID_FABRIC_INDEX` | A fabric index is invalid | +| 114 | 0x72 | `CHIP_ERROR_TOO_MANY_CONNECTIONS` | The attempt to allocate a connection object failed because too many connections exist | +| 115 | 0x73 | `CHIP_ERROR_SHUT_DOWN` | The operation cancelled because a shut down was initiated | +| 116 | 0x74 | `CHIP_ERROR_CANCELLED` | The operation has been cancelled, generally by calling a cancel/abort request | +| 117 | 0x75 | `CHIP_ERROR_DRBG_ENTROPY_SOURCE_FAILED` | DRBG entropy source failed to generate entropy data | +| 118 | 0x76 | `CHIP_ERROR_TLV_TAG_NOT_FOUND` | A specified TLV tag was not found | +| 119 | 0x77 | `CHIP_ERROR_MISSING_SECURE_SESSION` | A secure session is needed to do work, but is missing/is not present | +| 120 | 0x78 | `CHIP_ERROR_INVALID_ADMIN_SUBJECT` | The CaseAdminSubject field is not valid in AddNOC command | +| 121 | 0x79 | `CHIP_ERROR_INSUFFICIENT_PRIVILEGE` | Required privilege was insufficient during an operation | +| 122 | 0x7A | `CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_REPORT_IB` | The Attribute Report IB is malformed: it does not contain the required elements | +| 123 | 0x7B | `CHIP_ERROR_IM_MALFORMED_EVENT_STATUS_IB` | The Event Status IB is malformed: it does not contain the required elements | +| 124 | 0x7C | `CHIP_ERROR_IM_MALFORMED_STATUS_RESPONSE_MESSAGE` | The Status Response Message is malformed: it does not contain the required elements | +| 125 | 0x7D | `CHIP_ERROR_MESSAGE_COUNTER_EXHAUSTED` | The message counter of the session is exhausted, the session should be closed | +| 126 | 0x7E | `CHIP_ERROR_FABRIC_EXISTS` | The fabric with the given fabric id and root public key already exists | +| 127 | 0x7F | `CHIP_ERROR_KEY_NOT_FOUND_FROM_PEER` | The encryption key is not found error received from a peer node | +| 128 | 0x80 | `CHIP_ERROR_WRONG_ENCRYPTION_TYPE_FROM_PEER` | The wrong encryption type error received from a peer node | +| 129 | 0x81 | `CHIP_ERROR_UNKNOWN_KEY_TYPE_FROM_PEER` | The unknown key type error received from a peer node | +| 130 | 0x82 | `CHIP_ERROR_INVALID_USE_OF_SESSION_KEY_FROM_PEER` | The invalid use of session key error received from a peer node | +| 131 | 0x83 | `CHIP_ERROR_UNSUPPORTED_ENCRYPTION_TYPE_FROM_PEER` | An unsupported encryption type error received from a peer node | +| 132 | 0x84 | `CHIP_ERROR_INTERNAL_KEY_ERROR_FROM_PEER` | The internal key error received from a peer node | +| 133 | 0x85 | `CHIP_ERROR_INVALID_KEY_ID` | A key id is invalid | +| 134 | 0x86 | `CHIP_ERROR_INVALID_TIME` | Time has invalid value | +| 135 | 0x87 | `CHIP_ERROR_LOCKING_FAILURE` | Failure to acquire or release an OS provided mutex | +| 136 | 0x88 | `CHIP_ERROR_UNSUPPORTED_PASSCODE_CONFIG` | A passcode encryption configuration is unsupported | +| 137 | 0x89 | `CHIP_ERROR_PASSCODE_AUTHENTICATION_FAILED` | The CHIP passcode authentication failed | +| 138 | 0x8A | `CHIP_ERROR_PASSCODE_FINGERPRINT_FAILED` | The CHIP passcode fingerprint failed | +| 139 | 0x8B | `CHIP_ERROR_SERIALIZATION_ELEMENT_NULL` | The element of the struct is null | +| 140 | 0x8C | `CHIP_ERROR_WRONG_CERT_SIGNATURE_ALGORITHM` | The certificate was not signed using the required signature algorithm | +| 141 | 0x8D | `CHIP_ERROR_WRONG_CHIP_SIGNATURE_ALGORITHM` | The CHIP signature was not signed using the required signature algorithm | +| 142 | 0x8E | `CHIP_ERROR_SCHEMA_MISMATCH` | A mismatch in schema was encountered | +| 143 | 0x8F | `CHIP_ERROR_INVALID_INTEGER_VALUE` | An integer does not have the kind of value we expect | +| 144 | 0x90 | `CHIP_ERROR_CASE_RECONFIG_REQUIRED` | CASE is required to reconfigure | +| 145 | 0x91 | `CHIP_ERROR_TOO_MANY_CASE_RECONFIGURATIONS` | Too many CASE reconfigurations were received | +| 146 | 0x92 | `CHIP_ERROR_BAD_REQUEST` | The request cannot be processed or fulfilled | +| 147 | 0x93 | `CHIP_ERROR_INVALID_MESSAGE_FLAG` | One or more message flags have invalid value | +| 148 | 0x94 | `CHIP_ERROR_KEY_EXPORT_RECONFIGURE_REQUIRED` | Key export protocol required to reconfigure | +| 149 | 0x95 | `CHIP_ERROR_INVALID_KEY_EXPORT_CONFIGURATION` | A key export protocol configuration is invalid | +| 150 | 0x96 | `CHIP_ERROR_NO_COMMON_KEY_EXPORT_CONFIGURATIONS` | No key export protocol configuration is in common | +| 151 | 0x97 | `CHIP_ERROR_NO_KEY_EXPORT_DELEGATE` | No key export delegate is set | +| 152 | 0x98 | `CHIP_ERROR_UNAUTHORIZED_KEY_EXPORT_REQUEST` | Unauthorized key export request | +| 153 | 0x99 | `CHIP_ERROR_UNAUTHORIZED_KEY_EXPORT_RESPONSE` | Unauthorized key export response | +| 154 | 0x9A | `CHIP_ERROR_EXPORTED_KEY_AUTHENTICATION_FAILED` | The CHIP exported encrypted key authentication failed | +| 155 | 0x9B | `CHIP_ERROR_TOO_MANY_SHARED_SESSION_END_NODES` | The number of shared secure sessions end nodes exceeds the maximum limit | +| 156 | 0x9C | `CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_DATA_IB` | The Attribute Data IB is malformed: it does not contain the required elements | +| 157 | 0x9D | `CHIP_ERROR_WRONG_CERT_TYPE` | The presented certificate was of the wrong type | +| 158 | 0x9E | `CHIP_ERROR_DEFAULT_EVENT_HANDLER_NOT_CALLED` | The application's event handler failed to call the default event handler function when presented with an unknown event | +| 159 | 0x9F | `CHIP_ERROR_PERSISTED_STORAGE_FAILED` | Persisted storage memory read/write failure | +| 160 | 0xA0 | `CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND` | The specific value is not found in the persisted storage | +| 161 | 0xA1 | `CHIP_ERROR_IM_FABRIC_DELETED` | The fabric is deleted, and the corresponding IM resources are released | +| 162 | 0xA2 | `CHIP_ERROR_PROFILE_STRING_CONTEXT_NOT_REGISTERED` | The specified profile string support context is not registered | +| 163 | 0xA3 | `CHIP_ERROR_INCOMPATIBLE_SCHEMA_VERSION` | Encountered a mismatch in compatibility wrt to IDL schema version | +| 165 | 0xA5 | `CHIP_ERROR_ACCESS_DENIED` | The CHIP message is not granted access for further processing | +| 166 | 0xA6 | `CHIP_ERROR_UNKNOWN_RESOURCE_ID` | Unknown resource ID | +| 167 | 0xA7 | `CHIP_ERROR_VERSION_MISMATCH` | The conditional update of a trait instance path has failed because the local changes are based on an obsolete version of the data | +| 168 | 0xA8 | `CHIP_ERROR_UNSUPPORTED_THREAD_NETWORK_CREATE` | Device doesn't support standalone Thread network creation On some legacy devices new Thread network can only be created together with CHIP Fabric using CrateFabric() message | +| 169 | 0xA9 | `CHIP_ERROR_INCONSISTENT_CONDITIONALITY` | A TraitPath was declared updated with a conditionality that does not match that of other TraitPaths already updated in the same Trait Instance | +| 170 | 0xAA | `CHIP_ERROR_LOCAL_DATA_INCONSISTENT` | The local data does not match any known version of the Trait Instance and cannot support the operation requested | +| 171 | 0xAB | `CHIP_ERROR_EVENT_ID_FOUND` | Event ID matching the criteria was found | +| 172 | 0xAC | `CHIP_ERROR_INTERNAL` | Internal error | +| 173 | 0xAD | `CHIP_ERROR_OPEN_FAILED` | Open file failed | +| 174 | 0xAE | `CHIP_ERROR_READ_FAILED` | Read from file failed | +| 175 | 0xAF | `CHIP_ERROR_WRITE_FAILED` | Write to file failed | +| 176 | 0xB0 | `CHIP_ERROR_DECODE_FAILED` | Decoding failed | +| 177 | 0xB1 | `CHIP_ERROR_SESSION_KEY_SUSPENDED` | Use of the identified session key is suspended | +| 178 | 0xB2 | `CHIP_ERROR_UNSUPPORTED_WIRELESS_REGULATORY_DOMAIN` | The specified wireless regulatory domain is unsupported | +| 179 | 0xB3 | `CHIP_ERROR_UNSUPPORTED_WIRELESS_OPERATING_LOCATION` | The specified wireless operating location is unsupported | +| 180 | 0xB4 | `CHIP_ERROR_MDNS_COLLISION` | The registered service name has collision on the LAN | +| 181 | 0xB5 | `CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB` | The Attribute path IB is malformed: it does not contain the required path | +| 182 | 0xB6 | `CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB` | The Event Path IB is malformed: it does not contain the required elements | +| 183 | 0xB7 | `CHIP_ERROR_IM_MALFORMED_COMMAND_PATH_IB` | The Command Path IB is malformed: it does not contain the required elements | +| 184 | 0xB8 | `CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_STATUS_IB` | The Attribute Status IB is malformed: it does not contain the required elements | +| 185 | 0xB9 | `CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_IB` | The Command Data IB is malformed: it does not contain the required elements | +| 186 | 0xBA | `CHIP_ERROR_IM_MALFORMED_EVENT_DATA_IB` | The Event Data IB is malformed: it does not contain the required elements | +| 187 | 0xBB | `CHIP_ERROR_IM_MALFORMED_STATUS_IB` | The Attribute Data IB is malformed: it does not contain the required elements | +| 188 | 0xBC | `CHIP_ERROR_PEER_NODE_NOT_FOUND` | Unable to find the peer node | +| 189 | 0xBD | `CHIP_ERROR_HSM` | Error in Hardware security module Used for software fallback option | +| 190 | 0xBE | `CHIP_ERROR_INTERMEDIATE_CA_NOT_REQUIRED` | The commissioner doesn't require an intermediate CA to sign the operational certificates | +| 191 | 0xBF | `CHIP_ERROR_REAL_TIME_NOT_SYNCED` | The system's real time clock is not synchronized to an accurate time source | +| 192 | 0xC0 | `CHIP_ERROR_UNEXPECTED_EVENT` | An unexpected event was encountered | +| 193 | 0xC1 | `CHIP_ERROR_ENDPOINT_POOL_FULL` | No endpoint pool entry is available | +| 194 | 0xC2 | `CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG` | More inbound message data is pending than available buffer space available to copy it | +| 195 | 0xC3 | `CHIP_ERROR_OUTBOUND_MESSAGE_TOO_BIG` | More outbound message data is pending than available buffer space available to copy it | +| 196 | 0xC4 | `CHIP_ERROR_DUPLICATE_MESSAGE_RECEIVED` | The received message is a duplicate of a previously received message | +| 197 | 0xC5 | `CHIP_ERROR_INVALID_PUBLIC_KEY` | The received public key doesn't match locally generated key | +| 198 | 0xC6 | `CHIP_ERROR_FABRIC_MISMATCH_ON_ICA` | The fabric ID in ICA certificate doesn't match the one in NOC | +| 199 | 0xC7 | `CHIP_ERROR_MESSAGE_COUNTER_OUT_OF_WINDOW` | The message counter of the received message is out of receiving window | +| 200 | 0xC8 | `CHIP_ERROR_REBOOT_SIGNAL_RECEIVED` | Termination signal is received | +| 201 | 0xC9 | `CHIP_ERROR_NO_SHARED_TRUSTED_ROOT` | The CASE session could not be established as peer's credentials do not have a common root of trust | +| 202 | 0xCA | `CHIP_ERROR_IM_STATUS_CODE_RECEIVED` | The CASE session could not be established as peer's credentials do not have a common root of trust | +| 203 | 0xCB | `CHIP_ERROR_IM_MALFORMED_COMMAND_STATUS_IB` | The Command Status IB is malformed: it does not contain the required elements | +| 204 | 0xCC | `CHIP_ERROR_IM_MALFORMED_INVOKE_RESPONSE_IB` | The Invoke Response IB is malformed: it does not contain the required elements | +| 205 | 0xCD | `CHIP_ERROR_IM_MALFORMED_INVOKE_REQUEST_MESSAGE` | The Invoke Request Message is malformed: it does not contain the required elements | +| 206 | 0xCE | `CHIP_ERROR_IM_MALFORMED_INVOKE_RESPONSE_MESSAGE` | The Invoke Response Message is malformed: it does not contain the required elements | +| 207 | 0xCF | `CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_REPORT_MESSAGE` | The Attribute Response Message is malformed: it does not contain the required elements | +| 208 | 0xD0 | `CHIP_ERROR_IM_MALFORMED_WRITE_REQUEST_MESSAGE` | The Write Request Message is malformed: it does not contain the required elements | +| 209 | 0xD1 | `CHIP_ERROR_IM_MALFORMED_EVENT_FILTER_IB` | The Event Filter IB is malformed: it does not contain the required elements | +| 210 | 0xD2 | `CHIP_ERROR_IM_MALFORMED_READ_REQUEST_MESSAGE` | The Read Request Message is malformed: it does not contain the required elements | +| 211 | 0xD3 | `CHIP_ERROR_IM_MALFORMED_SUBSCRIBE_REQUEST_MESSAGE` | The Subscribe Request Message is malformed: it does not contain the required elements | +| 212 | 0xD4 | `CHIP_ERROR_IM_MALFORMED_SUBSCRIBE_RESPONSE_MESSAGE` | The Subscribe Response Message is malformed: it does not contain the required elements | +| 213 | 0xD5 | `CHIP_ERROR_IM_MALFORMED_EVENT_REPORT_IB` | The Event Report IB is malformed: it does not contain the required elements | +| 214 | 0xD6 | `CHIP_ERROR_IM_MALFORMED_CLUSTER_PATH_IB` | The Cluster Path IB is malformed: it does not contain the required elements | +| 215 | 0xD7 | `CHIP_ERROR_IM_MALFORMED_DATA_VERSION_FILTER_IB` | The Data Version Filter IB is malformed: it does not contain the required elements | +| 216 | 0xD8 | `CHIP_ERROR_NOT_FOUND` | The item referenced in the function call was not found | +| 217 | 0xD9 | `CHIP_ERROR_IM_MALFORMED_TIMED_REQUEST_MESSAGE` | The Timed Request Message is malformed: it does not contain the required elements | +| 218 | 0xDA | `CHIP_ERROR_INVALID_FILE_IDENTIFIER` | The file identifier, encoded in the first few bytes of a processed file, has unexpected value | +| 219 | 0xDB | `CHIP_ERROR_BUSY` | The Resource is busy and cannot process the request Trying again might work | +| 220 | 0xDC | `CHIP_ERROR_MAX_RETRY_EXCEEDED` | The maximum retry limit has been exceeded | +| 221 | 0xDD | `CHIP_ERROR_PROVIDER_LIST_EXHAUSTED` | The provider list has been exhausted | +| 222 | 0xDE | `CHIP_ERROR_ANOTHER_COMMISSIONING_IN_PROGRESS` | The provider list has been exhausted | +| 223 | 0xDF | `CHIP_ERROR_INVALID_SCHEME_PREFIX` | The scheme field contains an invalid prefix | +| 224 | 0xE0 | `CHIP_ERROR_MISSING_URI_SEPARATOR` | The URI separator is missing | + +## SDK Inet Layer errors + +| Decimal | Hex | Name | Description | +| ------- | ----- | ----------------------------------------- | ------------------------------------------------------------------------------------------ | +| 257 | 0x101 | `INET_ERROR_WRONG_ADDRESS_TYPE` | The Internet Protocol (IP) address type or scope does not match the expected type or scope | +| 258 | 0x102 | `INET_ERROR_PEER_DISCONNECTED` | A remote connection peer disconnected | +| 265 | 0x109 | `INET_ERROR_HOST_NOT_FOUND` | A requested host name could not be resolved to an address | +| 266 | 0x10A | `INET_ERROR_DNS_TRY_AGAIN` | A name server returned a temporary failure indication; try again later | +| 267 | 0x10B | `INET_ERROR_DNS_NO_RECOVERY` | A name server returned an unrecoverable error | +| 269 | 0x10D | `INET_ERROR_WRONG_PROTOCOL_TYPE` | An incorrect or unexpected protocol type was encountered | +| 270 | 0x10E | `INET_ERROR_UNKNOWN_INTERFACE` | An unknown interface identifier was encountered | +| 272 | 0x110 | `INET_ERROR_ADDRESS_NOT_FOUND` | A requested address type, class, or scope cannot be found | +| 273 | 0x111 | `INET_ERROR_HOST_NAME_TOO_LONG` | A requested host name is too long | +| 274 | 0x112 | `INET_ERROR_INVALID_HOST_NAME` | A requested host name and port is invalid | +| 277 | 0x115 | `INET_ERROR_IDLE_TIMEOUT` | A TCP connection timed out due to inactivity | +| 279 | 0x117 | `INET_ERROR_INVALID_IPV6_PKT` | An IPv6 packet is invalid | +| 280 | 0x118 | `INET_ERROR_INTERFACE_INIT_FAILURE` | Failure to initialize an interface | +| 281 | 0x119 | `INET_ERROR_TCP_USER_TIMEOUT` | TCP Connection timed out waiting for acknowledgment for transmitted packet | +| 282 | 0x11A | `INET_ERROR_TCP_CONNECT_TIMEOUT` | TCP Connection timed out waiting for a successful connection or a report of an error | +| 283 | 0x11B | `INET_ERROR_INCOMPATIBLE_IP_ADDRESS_TYPE` | The supplied text-form IP address was not compatible with the requested IP address type | + +## SDK Device Layer errors + +| Decimal | Hex | Name | Description | +| ------- | ----- | ------------------------------------------- | ----------------------------------------------- | +| 513 | 0x201 | `CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND` | The requested configuration value was not found | +| 514 | 0x202 | `CHIP_DEVICE_ERROR_NOT_SERVICE_PROVISIONED` | The device has not been service provisioned | +| 515 | 0x203 | `CHIP_DEVICE_ERROR_SOFTWARE_UPDATE_ABORTED` | The software update was aborted by application | +| 516 | 0x204 | `CHIP_DEVICE_ERROR_SOFTWARE_UPDATE_IGNORED` | The software update was ignored by application | + +## ASN.1 Layer errors + +| Decimal | Hex | Name | Description | +| ------- | ----- | --------------------------------- | ------------------------------------------------------------------------------------- | +| 768 | 0x300 | `ASN1_END` | An end of ASN1 container or stream condition occurred | +| 769 | 0x301 | `ASN1_ERROR_UNDERRUN` | The ASN1 encoding ended prematurely | +| 770 | 0x302 | `ASN1_ERROR_OVERFLOW` | The encoding exceeds the available space required to write it | +| 771 | 0x303 | `ASN1_ERROR_INVALID_STATE` | An unexpected or invalid state was encountered | +| 772 | 0x304 | `ASN1_ERROR_MAX_DEPTH_EXCEEDED` | The maximum number of container reading contexts was exceeded | +| 773 | 0x305 | `ASN1_ERROR_INVALID_ENCODING` | The ASN1 encoding is invalid | +| 774 | 0x306 | `ASN1_ERROR_UNSUPPORTED_ENCODING` | An unsupported encoding was requested or encountered | +| 775 | 0x307 | `ASN1_ERROR_TAG_OVERFLOW` | An encoded tag exceeds the available or allowed space required for it | +| 776 | 0x308 | `ASN1_ERROR_LENGTH_OVERFLOW` | An encoded length exceeds the available or allowed space required for it | +| 777 | 0x309 | `ASN1_ERROR_VALUE_OVERFLOW` | An encoded value exceeds the available or allowed space required for it | +| 778 | 0x30A | `ASN1_ERROR_UNKNOWN_OBJECT_ID` | A requested object identifier does not match the list of supported object identifiers | + +## BLE Layer errors + +| Decimal | Hex | Name | Description | +| ------- | ----- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| 1027 | 0x403 | `BLE_ERROR_NO_CONNECTION_RECEIVED_CALLBACK` | No callback was registered to receive a BLE Transport Protocol (BTP) connection | +| 1028 | 0x404 | `BLE_ERROR_CENTRAL_UNSUBSCRIBED` | A BLE central device unsubscribed from a peripheral device's BLE Transport Protocol (BTP) transmit characteristic | +| 1029 | 0x405 | `BLE_ERROR_GATT_SUBSCRIBE_FAILED` | A BLE central device failed to subscribe to a peripheral device's BLE Transport Protocol (BTP) transmit characteristic | +| 1030 | 0x406 | `BLE_ERROR_GATT_UNSUBSCRIBE_FAILED` | A BLE central device failed to unsubscribe from a peripheral device's BLE Transport Protocol (BTP) transmit characteristic | +| 1031 | 0x407 | `BLE_ERROR_GATT_WRITE_FAILED` | A General Attribute Profile (GATT) write operation failed | +| 1032 | 0x408 | `BLE_ERROR_GATT_INDICATE_FAILED` | A General Attribute Profile (GATT) indicate operation failed | +| 1035 | 0x40B | `BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT` | A BLE Transport Protocol (BTP) error was encountered | +| 1036 | 0x40C | `BLE_ERROR_REMOTE_DEVICE_DISCONNECTED` | A remote BLE connection peer disconnected, either actively or due to the expiration of a BLE connection supervision timeout | +| 1037 | 0x40D | `BLE_ERROR_APP_CLOSED_CONNECTION` | The local application closed a BLE connection, and has informed BleLayer | +| 1039 | 0x40F | `BLE_ERROR_NOT_CHIP_DEVICE` | A BLE peripheral device did not expose the General Attribute Profile (GATT) service required by the Bluetooth Transport Protocol (BTP) | +| 1040 | 0x410 | `BLE_ERROR_INCOMPATIBLE_PROTOCOL_VERSIONS` | A remote device does not offer a compatible version of the Bluetooth Transport Protocol (BTP) | +| 1043 | 0x413 | `BLE_ERROR_INVALID_FRAGMENT_SIZE` | A remote device selected in invalid Bluetooth Transport Protocol (BTP) fragment size | +| 1044 | 0x414 | `BLE_ERROR_START_TIMER_FAILED` | A timer failed to start within BleLayer | +| 1045 | 0x415 | `BLE_ERROR_CONNECT_TIMED_OUT` | A remote BLE peripheral device's Bluetooth Transport Protocol (BTP) connect handshake response timed out | +| 1046 | 0x416 | `BLE_ERROR_RECEIVE_TIMED_OUT` | A remote BLE central device's Bluetooth Transport Protocol (BTP) connect handshake timed out | +| 1047 | 0x417 | `BLE_ERROR_INVALID_MESSAGE` | An invalid Bluetooth Transport Protocol (BTP) message was received | +| 1048 | 0x418 | `BLE_ERROR_FRAGMENT_ACK_TIMED_OUT` | Receipt of an expected Bluetooth Transport Protocol (BTP) fragment acknowledgement timed out | +| 1049 | 0x419 | `BLE_ERROR_KEEP_ALIVE_TIMED_OUT` | Receipt of an expected Bluetooth Transport Protocol (BTP) keep-alive fragment timed out | +| 1050 | 0x41A | `BLE_ERROR_NO_CONNECT_COMPLETE_CALLBACK` | No callback was registered to handle Bluetooth Transport Protocol (BTP) connect completion | +| 1051 | 0x41B | `BLE_ERROR_INVALID_ACK` | A Bluetooth Transport Protcol (BTP) fragment acknowledgement was invalid | +| 1052 | 0x41C | `BLE_ERROR_REASSEMBLER_MISSING_DATA` | A Bluetooth Transport Protocol (BTP) end-of-message fragment was received, but the total size of the received fragments is less than the indicated size of the original fragmented message | +| 1053 | 0x41D | `BLE_ERROR_INVALID_BTP_HEADER_FLAGS` | A set of Bluetooth Transport Protocol (BTP) header flags is invalid | +| 1054 | 0x41E | `BLE_ERROR_INVALID_BTP_SEQUENCE_NUMBER` | A Bluetooth Transport Protocol (BTP) fragment sequence number is invalid | +| 1055 | 0x41F | `BLE_ERROR_REASSEMBLER_INCORRECT_STATE` | The Bluetooth Transport Protocol (BTP) message reassembly engine encountered an unexpected state | + +## IM Global errors errors + +| Decimal | Hex | Name | Description | +| ------- | ----- | -------------------------- | ----------- | +| 1280 | 0x500 | `SUCCESS` | | +| 1281 | 0x501 | `FAILURE` | | +| 1405 | 0x57D | `INVALID_SUBSCRIPTION` | | +| 1406 | 0x57E | `UNSUPPORTED_ACCESS` | | +| 1407 | 0x57F | `UNSUPPORTED_ENDPOINT` | | +| 1408 | 0x580 | `INVALID_ACTION` | | +| 1409 | 0x581 | `UNSUPPORTED_COMMAND` | | +| 1413 | 0x585 | `INVALID_COMMAND` | | +| 1414 | 0x586 | `UNSUPPORTED_ATTRIBUTE` | | +| 1415 | 0x587 | `CONSTRAINT_ERROR` | | +| 1416 | 0x588 | `UNSUPPORTED_WRITE` | | +| 1417 | 0x589 | `RESOURCE_EXHAUSTED` | | +| 1419 | 0x58B | `NOT_FOUND` | | +| 1420 | 0x58C | `UNREPORTABLE_ATTRIBUTE` | | +| 1421 | 0x58D | `INVALID_DATA_TYPE` | | +| 1423 | 0x58F | `UNSUPPORTED_READ` | | +| 1426 | 0x592 | `DATA_VERSION_MISMATCH` | | +| 1428 | 0x594 | `TIMEOUT` | | +| 1436 | 0x59C | `BUSY` | | +| 1475 | 0x5C3 | `UNSUPPORTED_CLUSTER` | | +| 1477 | 0x5C5 | `NO_UPSTREAM_SUBSCRIPTION` | | +| 1478 | 0x5C6 | `NEEDS_TIMED_INTERACTION` | | +| 1479 | 0x5C7 | `UNSUPPORTED_EVENT` | | +| 1480 | 0x5C8 | `PATHS_EXHAUSTED` | | +| 1481 | 0x5C9 | `TIMED_REQUEST_MISMATCH` | | +| 1482 | 0x5CA | `FAILSAFE_REQUIRED` | | +| 1520 | 0x5F0 | `WRITE_IGNORED` | | diff --git a/scripts/error_table.py b/scripts/error_table.py new file mode 100644 index 00000000000000..5bd1e7a1832acd --- /dev/null +++ b/scripts/error_table.py @@ -0,0 +1,151 @@ +#!/usr/bin/env python + +# +# Copyright (c) 2022 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Execute as `python scripts/error_table.py > docs/ERROR_CODES.md` from root of repos +# +# This script uses heuristics scraping of the headers to generate nice tables +# + +import re +from dataclasses import dataclass +from enum import IntEnum +from pathlib import Path +from operator import attrgetter + + +@dataclass +class ErrorCode: + code: int + name: str + description: str + + +@dataclass +class ErrorDescriptor: + section: str + code_range: int + # `macro_regex` needs to have `code` and `name` named groups. + macro_regex: str + omit_description: bool = False + + +class CommentState(IntEnum): + WAIT_START_COMMENT = 0 + ACCUMULATE_COMMENT = 1 + + +class ErrorCodeLoader: + def __init__(self) -> None: + self.reset() + + def reset(self): + self._comment_state = CommentState.WAIT_START_COMMENT + self._last_comment = [] + self._error_codes: list[ErrorCode] = [] + + def _process_comment_extract(self, line): + if self._comment_state == CommentState.WAIT_START_COMMENT: + if "/**" in line: + self._last_comment = [] + self._comment_state = CommentState.ACCUMULATE_COMMENT + elif self._comment_state == CommentState.ACCUMULATE_COMMENT: + if "*/" in line: + self._comment_state = CommentState.WAIT_START_COMMENT + else: + self._last_comment.append(line) + + def _process_error_extract(self, descriptor: ErrorDescriptor, line: str): + match = re.search(descriptor.macro_regex, line) + if match is None: + return + + last_comment = "".join(self._last_comment).replace(" ", " ").replace(" ", " ").replace("*", "").replace(".", "") + last_comment = last_comment.split("@brief")[-1].strip() + + code = int(match.group("code"), 0) + code = descriptor.code_range | code + name = match.group("name") + + description = "" if descriptor.omit_description else last_comment + self._error_codes.append(ErrorCode(code=code, name=name, description=description)) + + def load_error_header(self, filename: Path, descriptor: ErrorDescriptor) -> list[ErrorCode]: + self.reset() + + lines = filename.read_text().split("\n") + for line in lines: + line = line.strip() + self._process_comment_extract(line) + self._process_error_extract(descriptor, line) + + return self._error_codes + + +def get_section_title(section: str) -> tuple[str, str]: + markdown_title = f"{section} errors" + anchor_name = f'#{markdown_title.lower().replace(" ","-").replace(".","-")}' + + return markdown_title, anchor_name + + +def dump_table(header_path: Path, descriptor: ErrorDescriptor): + loader = ErrorCodeLoader() + codes_for_section = loader.load_error_header(header_path, descriptor) + + markdown_title, _ = get_section_title(descriptor.section) + print(f"## {markdown_title}") + print() + print("| Decimal | Hex | Name | Description |") + print("| --- | --- | --- | --- |") + + for code in sorted(codes_for_section, key=attrgetter("code")): + print(f"| {code.code} | 0x{code.code:02X} | `{code.name}` | {code.description} |") + + print() + + +def main(): + descriptors = { + "src/lib/core/CHIPError.h": ErrorDescriptor(section="SDK Core", code_range=0x000, macro_regex=r"^#define\s+(?P[_A-Z0-9]+)\s+CHIP(_CORE)?_ERROR[(](?P(0x[a-fA-F0-9]+)|\d+)[)]"), + "src/inet/InetError.h": ErrorDescriptor(section="SDK Inet Layer", code_range=0x100, macro_regex=r"^#define\s+(?P[_A-Z0-9]+)\s+CHIP_INET_ERROR[(](?P(0x[a-fA-F0-9]+)|\d+)[)]"), + "src/include/platform/CHIPDeviceError.h": ErrorDescriptor(section="SDK Device Layer", code_range=0x200, macro_regex=r"^#define\s+(?P[_A-Z0-9]+)\s+CHIP_DEVICE_ERROR[(](?P(0x[a-fA-F0-9]+)|\d+)[)]"), + "src/lib/asn1/ASN1Error.h": ErrorDescriptor(section="ASN.1 Layer", code_range=0x300, macro_regex=r"^#define\s+(?P[_A-Z0-9]+)\s+CHIP_ASN1_ERROR[(](?P(0x[a-fA-F0-9]+)|\d+)[)]"), + "src/ble/BleError.h": ErrorDescriptor(section="BLE Layer", code_range=0x400, macro_regex=r"^#define\s+(?P[_A-Z0-9]+)\s+CHIP_BLE_ERROR[(](?P(0x[a-fA-F0-9]+)|\d+)[)]"), + "src/protocols/interaction_model/StatusCodeList.h": ErrorDescriptor(section="IM Global errors", code_range=0x500, macro_regex=r"^CHIP_IM_STATUS_CODE[(][A-Za-z0-9_]+\s*,\s*(?P[A-Z0-9_]+)\s*,\s*(?P(0x[a-fA-F0-9]+)|\d+)[)]", omit_description=True), + } + + print("# Matter SDK `CHIP_ERROR` enums values") + print() + print("This file was **AUTOMATICALLY** generated by `python scripts/error_table.py > docs/ERROR_CODES.md`.") + print("DO NOT EDIT BY HAND!") + print() + print("## Table of contents") + + for descriptor in descriptors.values(): + markdown_title, anchor_name = get_section_title(descriptor.section) + print(f"- [{markdown_title}: range `0x{descriptor.code_range:03X}..0x{descriptor.code_range | 0xFF:03X}`]({anchor_name})") + print() + + for filename, descriptor in descriptors.items(): + dump_table(Path(filename), descriptor) + + +if __name__ == "__main__": + main()