Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify chip errors (rather than CHIP_ERROR, INET_ERROR, BLE_ERROR, ASN1_ERROR, System::Error etc) #7688

Closed
kpschoedel opened this issue Jun 16, 2021 · 2 comments · Fixed by #7916
Assignees

Comments

@kpschoedel
Copy link
Contributor

Problem

CHIP currently has CHIP_ERROR, INET_ERROR, BLE_ERROR, ASN1_ERROR, System::Error. Since they're all integers underneath, there is no type checking, and existing code routinely treats them as interchangeable.

Each type also has a …_NO_ERROR code which is independently configurable, but existing code assumes they are equal. It seems likely that there is also existing code that assumes the C/C++ convention that the no-error value is 0, but there is no practical way to look for this.

Proposed Solution

  • Unify error types into one, CHIP_ERROR.
  • Retain the existing numeric ranges (i.e. …_CONFIG_ERROR_MIN) and constant names within the unified type.
  • Consolidate exactly redundant codes (e.g. CHIP_SYSTEM_ERROR_NO_MEMORY, BLE_ERROR_NO_MEMORY, INET_ERROR_NO_MEMORYCHIP_ERROR_NO_MEMORY). Retain merely similar codes unless/until a domain expert decides they are redundant.
  • Remove configurability of CHIP_NO_ERROR — define it as 0.

As a followup, look for unnecessary error code remapping or erasure, to reduce code size.

@andy31415 andy31415 changed the title Mixed error types Unify chip errors (rather than CHIP_ERROR, INET_ERROR, BLE_ERROR, ASN1_ERROR, System::Error etc) Jun 17, 2021
@kpschoedel kpschoedel self-assigned this Jun 21, 2021
@kpschoedel
Copy link
Contributor Author

I'll take this as my morning warmup this week-ish.

@kpschoedel
Copy link
Contributor Author

Additional observations: There is in fact at least some existing code that assumes CHIP_NO_ERROR==0 with an in (fn()) test. There is also code (mostly shell and ironically tests) that treats CHIP_ERROR and int as interchangeable, and won't currently compile with picky options on platforms that have #define CHIP_CONFIG_ERROR_TYPE uint32_t.

kpschoedel added a commit to kpschoedel/connectedhomeip that referenced this issue Jun 25, 2021
CHIP currently has `CHIP_ERROR`, `INET_ERROR`, `BLE_ERROR`,
`ASN1_ERROR`, `System::Error`. Since they're all integers underneath,
there is no type checking, and existing code routinely treats them
as interchangeable. There is also existing code that uses `int` and
`int32_t`.  Each also has a `…_NO_ERROR` code which is independently
configurable, but existing code assumes they are equal, and there is
exising code that assumes the C convention that the value is 0.

#### Change overview

Fixes project-chip#7688 Unify chip errors

This change is largely a mechanical replacement of type and some error
code names, with a few cleanups of weak typing.

Consolidated error types to one, `CHIP_ERROR`.

Renamed or consolidated the following errors. This change contains
compatibility defintitions to avoid breaking PRs in flight; these
will be removed in a followup.

| ASN1_ERROR                             | CHIP_ERROR                          |
| ASN1_NO_ERROR                          | CHIP_NO_ERROR                       |
| BLE_ERROR                              | CHIP_ERROR                          |
| BLE_NO_ERROR                           | CHIP_NO_ERROR                       |
| BLE_ERROR_BAD_ARGS                     | CHIP_ERROR_INVALID_ARGUMENT         |
| BLE_ERROR_INCORRECT_STATE              | CHIP_ERROR_INCORRECT_STATE          |
| BLE_ERROR_MESSAGE_INCOMPLETE           | CHIP_ERROR_MESSAGE_INCOMPLETE       |
| BLE_ERROR_NOT_IMPLEMENTED              | CHIP_ERROR_NOT_IMPLEMENTED          |
| BLE_ERROR_NO_ENDPOINTS                 | CHIP_ERROR_ENDPOINT_POOL_FULL       |
| BLE_ERROR_NO_MEMORY                    | CHIP_ERROR_NO_MEMORY                |
| BLE_ERROR_OUTBOUND_MESSAGE_TOO_BIG     | CHIP_ERROR_OUTBOUND_MESSAGE_TOO_BIG |
| BLE_ERROR_RECEIVED_MESSAGE_TOO_BIG     | CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG  |
| CHIP_SYSTEM_NO_ERROR                   | CHIP_NO_ERROR                       |
| CHIP_SYSTEM_ERROR_ACCESS_DENIED        | CHIP_ERROR_ACCESS_DENIED            |
| CHIP_SYSTEM_ERROR_BAD_ARGS             | CHIP_ERROR_INVALID_ARGUMENT         |
| CHIP_SYSTEM_ERROR_NOT_SUPPORTED        | CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE |
| CHIP_SYSTEM_ERROR_NO_MEMORY            | CHIP_ERROR_NO_MEMORY                |
| CHIP_SYSTEM_ERROR_REAL_TIME_NOT_SYNCED | CHIP_ERROR_REAL_TIME_NOT_SYNCED     |
| CHIP_SYSTEM_ERROR_UNEXPECTED_EVENT     | CHIP_ERROR_UNEXPECTED_EVENT         |
| CHIP_SYSTEM_ERROR_UNEXPECTED_STATE     | CHIP_ERROR_INCORRECT_STATE          |
| INET_ERROR                             | CHIP_ERROR                          |
| INET_NO_ERROR                          | CHIP_NO_ERROR                       |
| INET_ERROR_BAD_ARGS                    | CHIP_ERROR_INVALID_ARGUMENT         |
| INET_ERROR_INBOUND_MESSAGE_TOO_BIG     | CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG  |
| INET_ERROR_INCORRECT_STATE             | CHIP_ERROR_INCORRECT_STATE          |
| INET_ERROR_MESSAGE_TOO_LONG            | CHIP_ERROR_MESSAGE_TOO_LONG         |
| INET_ERROR_NO_CONNECTION_HANDLER       | CHIP_ERROR_NO_CONNECTION_HANDLER    |
| INET_ERROR_NO_ENDPOINTS                | CHIP_ERROR_ENDPOINT_POOL_FULL       |
| INET_ERROR_NOT_IMPLEMENTED             | CHIP_ERROR_NOT_IMPLEMENTED          |
| INET_ERROR_NOT_SUPPORTED               | CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE |
| INET_ERROR_NO_MEMORY                   | CHIP_ERROR_NO_MEMORY                |
| INET_ERROR_CONNECTION_ABORTED          | CHIP_ERROR_CONNECTION_ABORTED       |

Added `CHIP_ERROR_SENTINEL` to replace the use of `CHIP_ERROR_MAX` as a
sentinel.

Added `CHIP_ERROR_FORMAT` to replace hardcode `PRI…32` in `printf()`
format strings.

#### Testing

Modified some unit tests to account for consolidated error codes.

Built locally with `CHIP_ERROR` hardcoded to `int32_t`, `uint32_t`,
`int16_t`, and `uint16_t` to shake out mistaken assumptions.
kpschoedel added a commit to kpschoedel/connectedhomeip that referenced this issue Jun 25, 2021
#### Problem

CHIP currently has `CHIP_ERROR`, `INET_ERROR`, `BLE_ERROR`,
`ASN1_ERROR`, `System::Error`. Since they're all integers underneath,
there is no type checking, and existing code routinely treats them
as interchangeable. There is also existing code that uses `int` and
`int32_t`.  Each also has a `…_NO_ERROR` code which is independently
configurable, but existing code assumes they are equal, and there is
exising code that assumes the C convention that the value is 0.

#### Change overview

Fixes project-chip#7688 Unify chip errors

This change is largely a mechanical replacement of type and some error
code names, with a few cleanups of weak typing.

Consolidated error types to one, `CHIP_ERROR`.

Removed configurability of `CHIP_NO_ERROR`; it must be 0.

Added `CHIP_ERROR_FORMAT` to replace hardcoded `PRI…32` in `printf()`
format strings.

Added `CHIP_ERROR_SENTINEL` to replace the use of `CHIP_ERROR_MAX` as a
sentinel.

Renamed or consolidated the following errors, which have the same
meaning. Merely similar codes are left alone. This change contains
compatibility defintitions to avoid breaking PRs in flight, which
will be removed in a followup.

| before                                 | after                               |
|:---------------------------------------|:------------------------------------|
| ASN1_ERROR                             | CHIP_ERROR                          |
| ASN1_NO_ERROR                          | CHIP_NO_ERROR                       |
| BLE_ERROR                              | CHIP_ERROR                          |
| BLE_NO_ERROR                           | CHIP_NO_ERROR                       |
| BLE_ERROR_BAD_ARGS                     | CHIP_ERROR_INVALID_ARGUMENT         |
| BLE_ERROR_INCORRECT_STATE              | CHIP_ERROR_INCORRECT_STATE          |
| BLE_ERROR_MESSAGE_INCOMPLETE           | CHIP_ERROR_MESSAGE_INCOMPLETE       |
| BLE_ERROR_NOT_IMPLEMENTED              | CHIP_ERROR_NOT_IMPLEMENTED          |
| BLE_ERROR_NO_ENDPOINTS                 | CHIP_ERROR_ENDPOINT_POOL_FULL       |
| BLE_ERROR_NO_MEMORY                    | CHIP_ERROR_NO_MEMORY                |
| BLE_ERROR_OUTBOUND_MESSAGE_TOO_BIG     | CHIP_ERROR_OUTBOUND_MESSAGE_TOO_BIG |
| BLE_ERROR_RECEIVED_MESSAGE_TOO_BIG     | CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG  |
| CHIP_SYSTEM_NO_ERROR                   | CHIP_NO_ERROR                       |
| CHIP_SYSTEM_ERROR_ACCESS_DENIED        | CHIP_ERROR_ACCESS_DENIED            |
| CHIP_SYSTEM_ERROR_BAD_ARGS             | CHIP_ERROR_INVALID_ARGUMENT         |
| CHIP_SYSTEM_ERROR_NOT_SUPPORTED        | CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE |
| CHIP_SYSTEM_ERROR_NO_MEMORY            | CHIP_ERROR_NO_MEMORY                |
| CHIP_SYSTEM_ERROR_REAL_TIME_NOT_SYNCED | CHIP_ERROR_REAL_TIME_NOT_SYNCED     |
| CHIP_SYSTEM_ERROR_UNEXPECTED_EVENT     | CHIP_ERROR_UNEXPECTED_EVENT         |
| CHIP_SYSTEM_ERROR_UNEXPECTED_STATE     | CHIP_ERROR_INCORRECT_STATE          |
| INET_ERROR                             | CHIP_ERROR                          |
| INET_NO_ERROR                          | CHIP_NO_ERROR                       |
| INET_ERROR_BAD_ARGS                    | CHIP_ERROR_INVALID_ARGUMENT         |
| INET_ERROR_INBOUND_MESSAGE_TOO_BIG     | CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG  |
| INET_ERROR_INCORRECT_STATE             | CHIP_ERROR_INCORRECT_STATE          |
| INET_ERROR_MESSAGE_TOO_LONG            | CHIP_ERROR_MESSAGE_TOO_LONG         |
| INET_ERROR_NO_CONNECTION_HANDLER       | CHIP_ERROR_NO_CONNECTION_HANDLER    |
| INET_ERROR_NO_ENDPOINTS                | CHIP_ERROR_ENDPOINT_POOL_FULL       |
| INET_ERROR_NOT_IMPLEMENTED             | CHIP_ERROR_NOT_IMPLEMENTED          |
| INET_ERROR_NOT_SUPPORTED               | CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE |
| INET_ERROR_NO_MEMORY                   | CHIP_ERROR_NO_MEMORY                |
| INET_ERROR_CONNECTION_ABORTED          | CHIP_ERROR_CONNECTION_ABORTED       |

#### Testing

Modified some unit tests to account for consolidated error codes.

Built locally with `CHIP_ERROR` hardcoded to `int32_t`, `uint32_t`,
`int16_t`, and `uint16_t` to shake out mistaken type assumptions.
woody-apple pushed a commit to kpschoedel/connectedhomeip that referenced this issue Jun 26, 2021
#### Problem

CHIP currently has `CHIP_ERROR`, `INET_ERROR`, `BLE_ERROR`,
`ASN1_ERROR`, `System::Error`. Since they're all integers underneath,
there is no type checking, and existing code routinely treats them
as interchangeable. There is also existing code that uses `int` and
`int32_t`.  Each also has a `…_NO_ERROR` code which is independently
configurable, but existing code assumes they are equal, and there is
exising code that assumes the C convention that the value is 0.

#### Change overview

Fixes project-chip#7688 Unify chip errors

This change is largely a mechanical replacement of type and some error
code names, with a few cleanups of weak typing.

Consolidated error types to one, `CHIP_ERROR`.

Removed configurability of `CHIP_NO_ERROR`; it must be 0.

Added `CHIP_ERROR_FORMAT` to replace hardcoded `PRI…32` in `printf()`
format strings.

Added `CHIP_ERROR_SENTINEL` to replace the use of `CHIP_ERROR_MAX` as a
sentinel.

Renamed or consolidated the following errors, which have the same
meaning. Merely similar codes are left alone. This change contains
compatibility defintitions to avoid breaking PRs in flight, which
will be removed in a followup.

| before                                 | after                               |
|:---------------------------------------|:------------------------------------|
| ASN1_ERROR                             | CHIP_ERROR                          |
| ASN1_NO_ERROR                          | CHIP_NO_ERROR                       |
| BLE_ERROR                              | CHIP_ERROR                          |
| BLE_NO_ERROR                           | CHIP_NO_ERROR                       |
| BLE_ERROR_BAD_ARGS                     | CHIP_ERROR_INVALID_ARGUMENT         |
| BLE_ERROR_INCORRECT_STATE              | CHIP_ERROR_INCORRECT_STATE          |
| BLE_ERROR_MESSAGE_INCOMPLETE           | CHIP_ERROR_MESSAGE_INCOMPLETE       |
| BLE_ERROR_NOT_IMPLEMENTED              | CHIP_ERROR_NOT_IMPLEMENTED          |
| BLE_ERROR_NO_ENDPOINTS                 | CHIP_ERROR_ENDPOINT_POOL_FULL       |
| BLE_ERROR_NO_MEMORY                    | CHIP_ERROR_NO_MEMORY                |
| BLE_ERROR_OUTBOUND_MESSAGE_TOO_BIG     | CHIP_ERROR_OUTBOUND_MESSAGE_TOO_BIG |
| BLE_ERROR_RECEIVED_MESSAGE_TOO_BIG     | CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG  |
| CHIP_SYSTEM_NO_ERROR                   | CHIP_NO_ERROR                       |
| CHIP_SYSTEM_ERROR_ACCESS_DENIED        | CHIP_ERROR_ACCESS_DENIED            |
| CHIP_SYSTEM_ERROR_BAD_ARGS             | CHIP_ERROR_INVALID_ARGUMENT         |
| CHIP_SYSTEM_ERROR_NOT_SUPPORTED        | CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE |
| CHIP_SYSTEM_ERROR_NO_MEMORY            | CHIP_ERROR_NO_MEMORY                |
| CHIP_SYSTEM_ERROR_REAL_TIME_NOT_SYNCED | CHIP_ERROR_REAL_TIME_NOT_SYNCED     |
| CHIP_SYSTEM_ERROR_UNEXPECTED_EVENT     | CHIP_ERROR_UNEXPECTED_EVENT         |
| CHIP_SYSTEM_ERROR_UNEXPECTED_STATE     | CHIP_ERROR_INCORRECT_STATE          |
| INET_ERROR                             | CHIP_ERROR                          |
| INET_NO_ERROR                          | CHIP_NO_ERROR                       |
| INET_ERROR_BAD_ARGS                    | CHIP_ERROR_INVALID_ARGUMENT         |
| INET_ERROR_INBOUND_MESSAGE_TOO_BIG     | CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG  |
| INET_ERROR_INCORRECT_STATE             | CHIP_ERROR_INCORRECT_STATE          |
| INET_ERROR_MESSAGE_TOO_LONG            | CHIP_ERROR_MESSAGE_TOO_LONG         |
| INET_ERROR_NO_CONNECTION_HANDLER       | CHIP_ERROR_NO_CONNECTION_HANDLER    |
| INET_ERROR_NO_ENDPOINTS                | CHIP_ERROR_ENDPOINT_POOL_FULL       |
| INET_ERROR_NOT_IMPLEMENTED             | CHIP_ERROR_NOT_IMPLEMENTED          |
| INET_ERROR_NOT_SUPPORTED               | CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE |
| INET_ERROR_NO_MEMORY                   | CHIP_ERROR_NO_MEMORY                |
| INET_ERROR_CONNECTION_ABORTED          | CHIP_ERROR_CONNECTION_ABORTED       |

#### Testing

Modified some unit tests to account for consolidated error codes.

Built locally with `CHIP_ERROR` hardcoded to `int32_t`, `uint32_t`,
`int16_t`, and `uint16_t` to shake out mistaken type assumptions.
kpschoedel added a commit to kpschoedel/connectedhomeip that referenced this issue Jun 28, 2021
#### Problem

CHIP currently has `CHIP_ERROR`, `INET_ERROR`, `BLE_ERROR`,
`ASN1_ERROR`, `System::Error`. Since they're all integers underneath,
there is no type checking, and existing code routinely treats them
as interchangeable. There is also existing code that uses `int` and
`int32_t`.  Each also has a `…_NO_ERROR` code which is independently
configurable, but existing code assumes they are equal, and there is
exising code that assumes the C convention that the value is 0.

#### Change overview

Fixes project-chip#7688 Unify chip errors

This change is largely a mechanical replacement of type and some error
code names, with a few cleanups of weak typing.

Consolidated error types to one, `CHIP_ERROR`.

Removed configurability of `CHIP_NO_ERROR`; it must be 0.

Added `CHIP_ERROR_FORMAT` to replace hardcoded `PRI…32` in `printf()`
format strings.

Added `CHIP_ERROR_SENTINEL` to replace the use of `CHIP_ERROR_MAX` as a
sentinel.

Renamed or consolidated the following errors, which have the same
meaning. Merely similar codes are left alone. This change contains
compatibility defintitions to avoid breaking PRs in flight, which
will be removed in a followup.

| before                                 | after                               |
|:---------------------------------------|:------------------------------------|
| ASN1_ERROR                             | CHIP_ERROR                          |
| ASN1_NO_ERROR                          | CHIP_NO_ERROR                       |
| BLE_ERROR                              | CHIP_ERROR                          |
| BLE_NO_ERROR                           | CHIP_NO_ERROR                       |
| BLE_ERROR_BAD_ARGS                     | CHIP_ERROR_INVALID_ARGUMENT         |
| BLE_ERROR_INCORRECT_STATE              | CHIP_ERROR_INCORRECT_STATE          |
| BLE_ERROR_MESSAGE_INCOMPLETE           | CHIP_ERROR_MESSAGE_INCOMPLETE       |
| BLE_ERROR_NOT_IMPLEMENTED              | CHIP_ERROR_NOT_IMPLEMENTED          |
| BLE_ERROR_NO_ENDPOINTS                 | CHIP_ERROR_ENDPOINT_POOL_FULL       |
| BLE_ERROR_NO_MEMORY                    | CHIP_ERROR_NO_MEMORY                |
| BLE_ERROR_OUTBOUND_MESSAGE_TOO_BIG     | CHIP_ERROR_OUTBOUND_MESSAGE_TOO_BIG |
| BLE_ERROR_RECEIVED_MESSAGE_TOO_BIG     | CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG  |
| CHIP_SYSTEM_NO_ERROR                   | CHIP_NO_ERROR                       |
| CHIP_SYSTEM_ERROR_ACCESS_DENIED        | CHIP_ERROR_ACCESS_DENIED            |
| CHIP_SYSTEM_ERROR_BAD_ARGS             | CHIP_ERROR_INVALID_ARGUMENT         |
| CHIP_SYSTEM_ERROR_NOT_SUPPORTED        | CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE |
| CHIP_SYSTEM_ERROR_NO_MEMORY            | CHIP_ERROR_NO_MEMORY                |
| CHIP_SYSTEM_ERROR_REAL_TIME_NOT_SYNCED | CHIP_ERROR_REAL_TIME_NOT_SYNCED     |
| CHIP_SYSTEM_ERROR_UNEXPECTED_EVENT     | CHIP_ERROR_UNEXPECTED_EVENT         |
| CHIP_SYSTEM_ERROR_UNEXPECTED_STATE     | CHIP_ERROR_INCORRECT_STATE          |
| INET_ERROR                             | CHIP_ERROR                          |
| INET_NO_ERROR                          | CHIP_NO_ERROR                       |
| INET_ERROR_BAD_ARGS                    | CHIP_ERROR_INVALID_ARGUMENT         |
| INET_ERROR_INBOUND_MESSAGE_TOO_BIG     | CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG  |
| INET_ERROR_INCORRECT_STATE             | CHIP_ERROR_INCORRECT_STATE          |
| INET_ERROR_MESSAGE_TOO_LONG            | CHIP_ERROR_MESSAGE_TOO_LONG         |
| INET_ERROR_NO_CONNECTION_HANDLER       | CHIP_ERROR_NO_CONNECTION_HANDLER    |
| INET_ERROR_NO_ENDPOINTS                | CHIP_ERROR_ENDPOINT_POOL_FULL       |
| INET_ERROR_NOT_IMPLEMENTED             | CHIP_ERROR_NOT_IMPLEMENTED          |
| INET_ERROR_NOT_SUPPORTED               | CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE |
| INET_ERROR_NO_MEMORY                   | CHIP_ERROR_NO_MEMORY                |
| INET_ERROR_CONNECTION_ABORTED          | CHIP_ERROR_CONNECTION_ABORTED       |

#### Testing

Modified some unit tests to account for consolidated error codes.

Built locally with `CHIP_ERROR` hardcoded to `int32_t`, `uint32_t`,
`int16_t`, and `uint16_t` to shake out mistaken type assumptions.
kpschoedel added a commit to kpschoedel/connectedhomeip that referenced this issue Jun 29, 2021
#### Problem

CHIP currently has `CHIP_ERROR`, `INET_ERROR`, `BLE_ERROR`,
`ASN1_ERROR`, `System::Error`. Since they're all integers underneath,
there is no type checking, and existing code routinely treats them
as interchangeable. There is also existing code that uses `int` and
`int32_t`.  Each also has a `…_NO_ERROR` code which is independently
configurable, but existing code assumes they are equal, and there is
exising code that assumes the C convention that the value is 0.

#### Change overview

Fixes project-chip#7688 Unify chip errors

This change is largely a mechanical replacement of type and some error
code names, with a few cleanups of weak typing.

Consolidated error types to one, `CHIP_ERROR`.

Removed configurability of `CHIP_NO_ERROR`; it must be 0.

Added `CHIP_ERROR_FORMAT` to replace hardcoded `PRI…32` in `printf()`
format strings.

Added `CHIP_ERROR_SENTINEL` to replace the use of `CHIP_ERROR_MAX` as a
sentinel.

Renamed or consolidated the following errors, which have the same
meaning. Merely similar codes are left alone. This change contains
compatibility defintitions to avoid breaking PRs in flight, which
will be removed in a followup.

| before                                 | after                               |
|:---------------------------------------|:------------------------------------|
| ASN1_ERROR                             | CHIP_ERROR                          |
| ASN1_NO_ERROR                          | CHIP_NO_ERROR                       |
| BLE_ERROR                              | CHIP_ERROR                          |
| BLE_NO_ERROR                           | CHIP_NO_ERROR                       |
| BLE_ERROR_BAD_ARGS                     | CHIP_ERROR_INVALID_ARGUMENT         |
| BLE_ERROR_INCORRECT_STATE              | CHIP_ERROR_INCORRECT_STATE          |
| BLE_ERROR_MESSAGE_INCOMPLETE           | CHIP_ERROR_MESSAGE_INCOMPLETE       |
| BLE_ERROR_NOT_IMPLEMENTED              | CHIP_ERROR_NOT_IMPLEMENTED          |
| BLE_ERROR_NO_ENDPOINTS                 | CHIP_ERROR_ENDPOINT_POOL_FULL       |
| BLE_ERROR_NO_MEMORY                    | CHIP_ERROR_NO_MEMORY                |
| BLE_ERROR_OUTBOUND_MESSAGE_TOO_BIG     | CHIP_ERROR_OUTBOUND_MESSAGE_TOO_BIG |
| BLE_ERROR_RECEIVED_MESSAGE_TOO_BIG     | CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG  |
| CHIP_SYSTEM_NO_ERROR                   | CHIP_NO_ERROR                       |
| CHIP_SYSTEM_ERROR_ACCESS_DENIED        | CHIP_ERROR_ACCESS_DENIED            |
| CHIP_SYSTEM_ERROR_BAD_ARGS             | CHIP_ERROR_INVALID_ARGUMENT         |
| CHIP_SYSTEM_ERROR_NOT_SUPPORTED        | CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE |
| CHIP_SYSTEM_ERROR_NO_MEMORY            | CHIP_ERROR_NO_MEMORY                |
| CHIP_SYSTEM_ERROR_REAL_TIME_NOT_SYNCED | CHIP_ERROR_REAL_TIME_NOT_SYNCED     |
| CHIP_SYSTEM_ERROR_UNEXPECTED_EVENT     | CHIP_ERROR_UNEXPECTED_EVENT         |
| CHIP_SYSTEM_ERROR_UNEXPECTED_STATE     | CHIP_ERROR_INCORRECT_STATE          |
| INET_ERROR                             | CHIP_ERROR                          |
| INET_NO_ERROR                          | CHIP_NO_ERROR                       |
| INET_ERROR_BAD_ARGS                    | CHIP_ERROR_INVALID_ARGUMENT         |
| INET_ERROR_INBOUND_MESSAGE_TOO_BIG     | CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG  |
| INET_ERROR_INCORRECT_STATE             | CHIP_ERROR_INCORRECT_STATE          |
| INET_ERROR_MESSAGE_TOO_LONG            | CHIP_ERROR_MESSAGE_TOO_LONG         |
| INET_ERROR_NO_CONNECTION_HANDLER       | CHIP_ERROR_NO_CONNECTION_HANDLER    |
| INET_ERROR_NO_ENDPOINTS                | CHIP_ERROR_ENDPOINT_POOL_FULL       |
| INET_ERROR_NOT_IMPLEMENTED             | CHIP_ERROR_NOT_IMPLEMENTED          |
| INET_ERROR_NOT_SUPPORTED               | CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE |
| INET_ERROR_NO_MEMORY                   | CHIP_ERROR_NO_MEMORY                |
| INET_ERROR_CONNECTION_ABORTED          | CHIP_ERROR_CONNECTION_ABORTED       |

#### Testing

Modified some unit tests to account for consolidated error codes.

Built locally with `CHIP_ERROR` hardcoded to `int32_t`, `uint32_t`,
`int16_t`, and `uint16_t` to shake out mistaken type assumptions.
mspang pushed a commit that referenced this issue Jun 30, 2021
* Consolidate error types

#### Problem

CHIP currently has `CHIP_ERROR`, `INET_ERROR`, `BLE_ERROR`,
`ASN1_ERROR`, `System::Error`. Since they're all integers underneath,
there is no type checking, and existing code routinely treats them
as interchangeable. There is also existing code that uses `int` and
`int32_t`.  Each also has a `…_NO_ERROR` code which is independently
configurable, but existing code assumes they are equal, and there is
exising code that assumes the C convention that the value is 0.

#### Change overview

Fixes #7688 Unify chip errors

This change is largely a mechanical replacement of type and some error
code names, with a few cleanups of weak typing.

Consolidated error types to one, `CHIP_ERROR`.

Removed configurability of `CHIP_NO_ERROR`; it must be 0.

Added `CHIP_ERROR_FORMAT` to replace hardcoded `PRI…32` in `printf()`
format strings.

Added `CHIP_ERROR_SENTINEL` to replace the use of `CHIP_ERROR_MAX` as a
sentinel.

Renamed or consolidated the following errors, which have the same
meaning. Merely similar codes are left alone. This change contains
compatibility defintitions to avoid breaking PRs in flight, which
will be removed in a followup.

| before                                 | after                               |
|:---------------------------------------|:------------------------------------|
| ASN1_ERROR                             | CHIP_ERROR                          |
| ASN1_NO_ERROR                          | CHIP_NO_ERROR                       |
| BLE_ERROR                              | CHIP_ERROR                          |
| BLE_NO_ERROR                           | CHIP_NO_ERROR                       |
| BLE_ERROR_BAD_ARGS                     | CHIP_ERROR_INVALID_ARGUMENT         |
| BLE_ERROR_INCORRECT_STATE              | CHIP_ERROR_INCORRECT_STATE          |
| BLE_ERROR_MESSAGE_INCOMPLETE           | CHIP_ERROR_MESSAGE_INCOMPLETE       |
| BLE_ERROR_NOT_IMPLEMENTED              | CHIP_ERROR_NOT_IMPLEMENTED          |
| BLE_ERROR_NO_ENDPOINTS                 | CHIP_ERROR_ENDPOINT_POOL_FULL       |
| BLE_ERROR_NO_MEMORY                    | CHIP_ERROR_NO_MEMORY                |
| BLE_ERROR_OUTBOUND_MESSAGE_TOO_BIG     | CHIP_ERROR_OUTBOUND_MESSAGE_TOO_BIG |
| BLE_ERROR_RECEIVED_MESSAGE_TOO_BIG     | CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG  |
| CHIP_SYSTEM_NO_ERROR                   | CHIP_NO_ERROR                       |
| CHIP_SYSTEM_ERROR_ACCESS_DENIED        | CHIP_ERROR_ACCESS_DENIED            |
| CHIP_SYSTEM_ERROR_BAD_ARGS             | CHIP_ERROR_INVALID_ARGUMENT         |
| CHIP_SYSTEM_ERROR_NOT_SUPPORTED        | CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE |
| CHIP_SYSTEM_ERROR_NO_MEMORY            | CHIP_ERROR_NO_MEMORY                |
| CHIP_SYSTEM_ERROR_REAL_TIME_NOT_SYNCED | CHIP_ERROR_REAL_TIME_NOT_SYNCED     |
| CHIP_SYSTEM_ERROR_UNEXPECTED_EVENT     | CHIP_ERROR_UNEXPECTED_EVENT         |
| CHIP_SYSTEM_ERROR_UNEXPECTED_STATE     | CHIP_ERROR_INCORRECT_STATE          |
| INET_ERROR                             | CHIP_ERROR                          |
| INET_NO_ERROR                          | CHIP_NO_ERROR                       |
| INET_ERROR_BAD_ARGS                    | CHIP_ERROR_INVALID_ARGUMENT         |
| INET_ERROR_INBOUND_MESSAGE_TOO_BIG     | CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG  |
| INET_ERROR_INCORRECT_STATE             | CHIP_ERROR_INCORRECT_STATE          |
| INET_ERROR_MESSAGE_TOO_LONG            | CHIP_ERROR_MESSAGE_TOO_LONG         |
| INET_ERROR_NO_CONNECTION_HANDLER       | CHIP_ERROR_NO_CONNECTION_HANDLER    |
| INET_ERROR_NO_ENDPOINTS                | CHIP_ERROR_ENDPOINT_POOL_FULL       |
| INET_ERROR_NOT_IMPLEMENTED             | CHIP_ERROR_NOT_IMPLEMENTED          |
| INET_ERROR_NOT_SUPPORTED               | CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE |
| INET_ERROR_NO_MEMORY                   | CHIP_ERROR_NO_MEMORY                |
| INET_ERROR_CONNECTION_ABORTED          | CHIP_ERROR_CONNECTION_ABORTED       |

#### Testing

Modified some unit tests to account for consolidated error codes.

Built locally with `CHIP_ERROR` hardcoded to `int32_t`, `uint32_t`,
`int16_t`, and `uint16_t` to shake out mistaken type assumptions.

* Build fixes

* Darwin
* Doxygen

* Fixes

* Change default CHIP_CONFIG_ERROR_TYPE back to `int32_t`.
* Fix CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG message text.
* C++-style casts.

* fix: CHIPError.h uses stdint.h

* zap

* fix for Mbed merge
woody-apple added a commit that referenced this issue Jul 3, 2021
* add electrical measurement cluster to controller-clusters.zap

Only a selection of the optional clusters is enabled.

mandatory:
- measurement type

optional:
- total active power
- rms voltage
- rms voltage min
- rms voltage max
- rms current
- rms current min
- rms current max
- active power
- active power min
- active power max

* add electrical measurement cluster to zap_cluster_list.py

* add electrical measurement cluster to all-clusters-app

* add electrical measurement cluster to all-cluster-app/esp32

* add app helpers for electrical measurement cluster

* fix all cluster app build

* regen all

* Regenerating

* Restyled by whitespace

* Restyled by clang-format

* Regenerating

* Restyled by whitespace

* Restyled by google-java-format

* [fix] Wrong callback passed to WriteAttribute in Python[TE4] (#8019)

* Fix callback typr

* Run codegen

* Mdns: _chip* -> _matter*, remove 0's on subtypes (#7805)

* Mdns: _chip* i-> _matter*, remove 0's on subtypes

The second ballot changed the format of the subtypes as well as
fixed the service name prefix from _chip* to _matter*.

NOTE FOR DEVs: Updating past this change will require updating the
devices and controllers as otherwise they will be unable to find
each other.

* Darwin - use local kLocalDomain var.

It includes a . and the one in the ServiceNaming doesn't.

* Trying again for Darwin.

* Fix host name.

* Fix small error on merge

* Use a dedicated chip-types.xml file into src/app/zap-templates/zcl (#7873)

* Update chip-types.xml

* Update gen/ folders

* Revert "Mark UDP socket as ready for write in send msg. (#7927)" (#8027)

Turns out the code causes that subsequent select()-s never
wait so another solution for the original issue must be
prepared.

This reverts commit 8c55523.

* [ZAP] Add isAnalog instead of isDiscreteType to account for string types (#7821)

* Mdns: separate query responders for advertisers (#7615)

* Mdns: separate query responders for advertisers

The current setup uses a single query responder for commissionable
and operational and all the records are cleared together and added
in a large group. This makes it challenging to run commissionable
and operational at the same time since they can't be cleared
individually and because there are duplicate records between
operational and commissionable. This commit changes the code to
use one query responder per advertisement type and gets the
ResponseSender to loop through the query responders to filter
for answers.

* Apply suggestions from code review

Co-authored-by: chrisdecenzo <[email protected]>

* Restyled by clang-format

* Fix tests - they were not testing right.

* Restyled by clang-format

* Update number of responders

Represents 5 multi-admin fabrics for operational, commissionable
and commissioner.

* Whoops - broke a test with my last "minor" change.

* Lighten the stack load for the failing test.

Co-authored-by: chrisdecenzo <[email protected]>
Co-authored-by: Restyled.io <[email protected]>

* [nrfconnect] Stop using cooperative threads (#8025)

nRF Connect platform used cooperative threads, that is
threads that cannot be preempted, to workaround some
synchronization issues in the past, but it's no longer
needed and is risky. The latter was revealed by #7927,
which caused that `select()` never waits (needs to be
fixed in another PR).

Signed-off-by: Damian Krolik <[email protected]>

* IPV6-only test app for esp32 (examples/ipv6only-app) (#7289)

Adds RPCs that conform to NDM/GDM WiFi capabilities.
Disables IPV4 DHCP client. Assigns link-local IPV6 address.
Starts a UDP echo server on an IPV6 UDP socket.

Test: Ran on M5Stack and verified it scanned and connected to wifi,
after connected verified it echoed UDP messages.

* [ESP32] fix compile error for persistent-storage app (#7940)

* [ESP32] fix compile error for persistent-storage app

* add CI for all ESP examples

* Consolidate error types (#7916)

* Consolidate error types

#### Problem

CHIP currently has `CHIP_ERROR`, `INET_ERROR`, `BLE_ERROR`,
`ASN1_ERROR`, `System::Error`. Since they're all integers underneath,
there is no type checking, and existing code routinely treats them
as interchangeable. There is also existing code that uses `int` and
`int32_t`.  Each also has a `…_NO_ERROR` code which is independently
configurable, but existing code assumes they are equal, and there is
exising code that assumes the C convention that the value is 0.

#### Change overview

Fixes #7688 Unify chip errors

This change is largely a mechanical replacement of type and some error
code names, with a few cleanups of weak typing.

Consolidated error types to one, `CHIP_ERROR`.

Removed configurability of `CHIP_NO_ERROR`; it must be 0.

Added `CHIP_ERROR_FORMAT` to replace hardcoded `PRI…32` in `printf()`
format strings.

Added `CHIP_ERROR_SENTINEL` to replace the use of `CHIP_ERROR_MAX` as a
sentinel.

Renamed or consolidated the following errors, which have the same
meaning. Merely similar codes are left alone. This change contains
compatibility defintitions to avoid breaking PRs in flight, which
will be removed in a followup.

| before                                 | after                               |
|:---------------------------------------|:------------------------------------|
| ASN1_ERROR                             | CHIP_ERROR                          |
| ASN1_NO_ERROR                          | CHIP_NO_ERROR                       |
| BLE_ERROR                              | CHIP_ERROR                          |
| BLE_NO_ERROR                           | CHIP_NO_ERROR                       |
| BLE_ERROR_BAD_ARGS                     | CHIP_ERROR_INVALID_ARGUMENT         |
| BLE_ERROR_INCORRECT_STATE              | CHIP_ERROR_INCORRECT_STATE          |
| BLE_ERROR_MESSAGE_INCOMPLETE           | CHIP_ERROR_MESSAGE_INCOMPLETE       |
| BLE_ERROR_NOT_IMPLEMENTED              | CHIP_ERROR_NOT_IMPLEMENTED          |
| BLE_ERROR_NO_ENDPOINTS                 | CHIP_ERROR_ENDPOINT_POOL_FULL       |
| BLE_ERROR_NO_MEMORY                    | CHIP_ERROR_NO_MEMORY                |
| BLE_ERROR_OUTBOUND_MESSAGE_TOO_BIG     | CHIP_ERROR_OUTBOUND_MESSAGE_TOO_BIG |
| BLE_ERROR_RECEIVED_MESSAGE_TOO_BIG     | CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG  |
| CHIP_SYSTEM_NO_ERROR                   | CHIP_NO_ERROR                       |
| CHIP_SYSTEM_ERROR_ACCESS_DENIED        | CHIP_ERROR_ACCESS_DENIED            |
| CHIP_SYSTEM_ERROR_BAD_ARGS             | CHIP_ERROR_INVALID_ARGUMENT         |
| CHIP_SYSTEM_ERROR_NOT_SUPPORTED        | CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE |
| CHIP_SYSTEM_ERROR_NO_MEMORY            | CHIP_ERROR_NO_MEMORY                |
| CHIP_SYSTEM_ERROR_REAL_TIME_NOT_SYNCED | CHIP_ERROR_REAL_TIME_NOT_SYNCED     |
| CHIP_SYSTEM_ERROR_UNEXPECTED_EVENT     | CHIP_ERROR_UNEXPECTED_EVENT         |
| CHIP_SYSTEM_ERROR_UNEXPECTED_STATE     | CHIP_ERROR_INCORRECT_STATE          |
| INET_ERROR                             | CHIP_ERROR                          |
| INET_NO_ERROR                          | CHIP_NO_ERROR                       |
| INET_ERROR_BAD_ARGS                    | CHIP_ERROR_INVALID_ARGUMENT         |
| INET_ERROR_INBOUND_MESSAGE_TOO_BIG     | CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG  |
| INET_ERROR_INCORRECT_STATE             | CHIP_ERROR_INCORRECT_STATE          |
| INET_ERROR_MESSAGE_TOO_LONG            | CHIP_ERROR_MESSAGE_TOO_LONG         |
| INET_ERROR_NO_CONNECTION_HANDLER       | CHIP_ERROR_NO_CONNECTION_HANDLER    |
| INET_ERROR_NO_ENDPOINTS                | CHIP_ERROR_ENDPOINT_POOL_FULL       |
| INET_ERROR_NOT_IMPLEMENTED             | CHIP_ERROR_NOT_IMPLEMENTED          |
| INET_ERROR_NOT_SUPPORTED               | CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE |
| INET_ERROR_NO_MEMORY                   | CHIP_ERROR_NO_MEMORY                |
| INET_ERROR_CONNECTION_ABORTED          | CHIP_ERROR_CONNECTION_ABORTED       |

#### Testing

Modified some unit tests to account for consolidated error codes.

Built locally with `CHIP_ERROR` hardcoded to `int32_t`, `uint32_t`,
`int16_t`, and `uint16_t` to shake out mistaken type assumptions.

* Build fixes

* Darwin
* Doxygen

* Fixes

* Change default CHIP_CONFIG_ERROR_TYPE back to `int32_t`.
* Fix CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG message text.
* C++-style casts.

* fix: CHIPError.h uses stdint.h

* zap

* fix for Mbed merge

* Throw exception instead of return 0 for get-fabricid in case of error (#7884)

* Implement User Directed Commissioning - Phase 1 (#8034)

* Updated CHIP Certs Implementation to Use Spans instaed of Pointer/Len Pairs. (#7599)

Specifically, added the following FixedSpan types:
  - CertificateKeyId
  - P256ECDSASignatureSpan
  - P256PublicKeySpan
Also redefined mString member in the ChipRDN structure to be ByteSpan.

* Zap use const expr for clusters commands attributes (#7946)

* Remove duplicated command ids and attribute ids definitions from the encoder-src.zapt template

Add ids/Commands.zapt template

Update template to use Commands.h and Clusters.h

* Fix XML definitions typos for attributes name

* Add ids/Commands.h to the gen folder of src/app/common

* Update log messages for session expiry (#8017)

* Update log messages for session expiry

* update format specifier

* Remove client-command-macro.h-aa80d825 from examples/bridge-app/bridge-common/gen (#8026)

* Fix Ble endpoint pool FULL on macOS controller (#7806)

* * Move naming qpg6100 to qpg (#7936)

* Removal Env overrides sdk root and target IC

* fix build error in TCP.cpp (#8072)

Include <limits> to satisfy the proper use of std::numeric_limits.

* Add lighting example for Mbed OS (#8048)

* Add back structs, bitmaps and enums of the Messaging cluster into ami… (#8061)

* Add back structs, bitmaps and enums of the Messaging cluster into ami.xml

* Update gen/ folders

* Deprecated ASN1Writer::Finalize() Method. (#8056)

* Split KeyValueStoreManager.java into interface and impl, and add Set() in JNI. (#8046)

* [Test] Add Test_TC_DM_3_1 (#8067)

* Add Test_TC_DM_3_1 to src/app/tests/suites with all tests disabled since the attributes are not present into commissioning.xml

* Update generated tests

* Followup #7873 - Replace emberAfPutInt8uInResp(ZCL_DEFAULT_RESPONSE_COMMAND_ID) by emberAfPutInt32uInResp(ZCL_DEFAULT_RESPONSE_COMMAND_ID) in src/app/util/util.cpp (#8060)

* Remove call-command-handler.cpp from src/controller/data_model/gen/ and from src/darwin/Framework/CHIP.xcodeproj/project.pbxproj (#8021)

* Add PID to Darwin/Linux Log Lines (#7657)

* Add PID to Darwin/Linux Log Lines

Problem:
- Debugging test failures that involve multiple instances of
  applications is difficult when the log lines don't indicate which
  process/application they're coming from.

Solution:
- Added PID to the log lines on Darwin & Linux minimally to aid in
  debugging.

Testing:
- Ran chip-tool on both platforms.

* Restyled by clang-format

Co-authored-by: Restyled.io <[email protected]>

* Update Darwin framework to use GetConnectedDevice (#8011)

* Update Darwin framework to use GetConnectedDevice

* address review comments

* Add a string circular buffer. (#7475)

* Add a string circular buffer.

* Update src/lib/support/StringCircularBuffer.cpp

Co-authored-by: Boris Zbarsky <[email protected]>

* Update src/lib/support/StringCircularBuffer.cpp

Co-authored-by: Boris Zbarsky <[email protected]>

* Update src/lib/support/StringCircularBuffer.cpp

Co-authored-by: Boris Zbarsky <[email protected]>

* Resolve comments

* Resolve comments

* Resolve comments

* Resolve comments

Co-authored-by: Justin Wood <[email protected]>
Co-authored-by: Boris Zbarsky <[email protected]>

* [lighting-app] Enable optional Basic Cluster attributes (#8083)

* [lighting-app] Enable optional Basic Cluster attributes

Enable optional Basic Cluster attributes as requested by
Chaintanya, to verify a proper behaviour of the Python
controller.

* Re-gen code

* Add GenerateEventPathList and test (#8014)

Summary of Changes:
-- Add GenerateEventPathList function in ReadClinet
-- Add one event path test and two event path test
-- Fix im e2e cirque test in chip_im_responder from PR 7634 since cirque test is not
enabled

* Have a single loopback transport implementation for tests. (#8045)

We have multiple, some with different bells and whistles.  Should have one shared thing.

Unfortunately, some consumers want to drive things off the loopback
(like resending reliable messages) that other consumers can't know
about because they are at lower layers of the stack.  We just use a
virtual hook for that for now.

* Don't treat a resolve as done in chip-device-ctrl until we have a CASE connection. (#8012)

This ensures that following commands will work instead of racing the
CASE connection setup.

* Regenerating

* Restyled by whitespace

* Restyled by google-java-format

* Regenerating

Co-authored-by: Justin Wood <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Song Guo <[email protected]>
Co-authored-by: C Freeman <[email protected]>
Co-authored-by: Vivien Nicolas <[email protected]>
Co-authored-by: Damian Królik <[email protected]>
Co-authored-by: chrisdecenzo <[email protected]>
Co-authored-by: rgoliver <[email protected]>
Co-authored-by: Wang Qixiang <[email protected]>
Co-authored-by: Kevin Schoedel <[email protected]>
Co-authored-by: Yufeng Wang <[email protected]>
Co-authored-by: Evgeny Margolis <[email protected]>
Co-authored-by: Pankaj Garg <[email protected]>
Co-authored-by: krypton36 <[email protected]>
Co-authored-by: Timothy Maes <[email protected]>
Co-authored-by: CodeChronos <[email protected]>
Co-authored-by: Vincent Coubard <[email protected]>
Co-authored-by: Austin Hsieh <[email protected]>
Co-authored-by: Jerry Johns <[email protected]>
Co-authored-by: Zang MingJie <[email protected]>
Co-authored-by: Boris Zbarsky <[email protected]>
Co-authored-by: yunhanw-google <[email protected]>
nikita-s-wrk pushed a commit to nikita-s-wrk/connectedhomeip that referenced this issue Sep 23, 2021
* Consolidate error types

#### Problem

CHIP currently has `CHIP_ERROR`, `INET_ERROR`, `BLE_ERROR`,
`ASN1_ERROR`, `System::Error`. Since they're all integers underneath,
there is no type checking, and existing code routinely treats them
as interchangeable. There is also existing code that uses `int` and
`int32_t`.  Each also has a `…_NO_ERROR` code which is independently
configurable, but existing code assumes they are equal, and there is
exising code that assumes the C convention that the value is 0.

#### Change overview

Fixes project-chip#7688 Unify chip errors

This change is largely a mechanical replacement of type and some error
code names, with a few cleanups of weak typing.

Consolidated error types to one, `CHIP_ERROR`.

Removed configurability of `CHIP_NO_ERROR`; it must be 0.

Added `CHIP_ERROR_FORMAT` to replace hardcoded `PRI…32` in `printf()`
format strings.

Added `CHIP_ERROR_SENTINEL` to replace the use of `CHIP_ERROR_MAX` as a
sentinel.

Renamed or consolidated the following errors, which have the same
meaning. Merely similar codes are left alone. This change contains
compatibility defintitions to avoid breaking PRs in flight, which
will be removed in a followup.

| before                                 | after                               |
|:---------------------------------------|:------------------------------------|
| ASN1_ERROR                             | CHIP_ERROR                          |
| ASN1_NO_ERROR                          | CHIP_NO_ERROR                       |
| BLE_ERROR                              | CHIP_ERROR                          |
| BLE_NO_ERROR                           | CHIP_NO_ERROR                       |
| BLE_ERROR_BAD_ARGS                     | CHIP_ERROR_INVALID_ARGUMENT         |
| BLE_ERROR_INCORRECT_STATE              | CHIP_ERROR_INCORRECT_STATE          |
| BLE_ERROR_MESSAGE_INCOMPLETE           | CHIP_ERROR_MESSAGE_INCOMPLETE       |
| BLE_ERROR_NOT_IMPLEMENTED              | CHIP_ERROR_NOT_IMPLEMENTED          |
| BLE_ERROR_NO_ENDPOINTS                 | CHIP_ERROR_ENDPOINT_POOL_FULL       |
| BLE_ERROR_NO_MEMORY                    | CHIP_ERROR_NO_MEMORY                |
| BLE_ERROR_OUTBOUND_MESSAGE_TOO_BIG     | CHIP_ERROR_OUTBOUND_MESSAGE_TOO_BIG |
| BLE_ERROR_RECEIVED_MESSAGE_TOO_BIG     | CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG  |
| CHIP_SYSTEM_NO_ERROR                   | CHIP_NO_ERROR                       |
| CHIP_SYSTEM_ERROR_ACCESS_DENIED        | CHIP_ERROR_ACCESS_DENIED            |
| CHIP_SYSTEM_ERROR_BAD_ARGS             | CHIP_ERROR_INVALID_ARGUMENT         |
| CHIP_SYSTEM_ERROR_NOT_SUPPORTED        | CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE |
| CHIP_SYSTEM_ERROR_NO_MEMORY            | CHIP_ERROR_NO_MEMORY                |
| CHIP_SYSTEM_ERROR_REAL_TIME_NOT_SYNCED | CHIP_ERROR_REAL_TIME_NOT_SYNCED     |
| CHIP_SYSTEM_ERROR_UNEXPECTED_EVENT     | CHIP_ERROR_UNEXPECTED_EVENT         |
| CHIP_SYSTEM_ERROR_UNEXPECTED_STATE     | CHIP_ERROR_INCORRECT_STATE          |
| INET_ERROR                             | CHIP_ERROR                          |
| INET_NO_ERROR                          | CHIP_NO_ERROR                       |
| INET_ERROR_BAD_ARGS                    | CHIP_ERROR_INVALID_ARGUMENT         |
| INET_ERROR_INBOUND_MESSAGE_TOO_BIG     | CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG  |
| INET_ERROR_INCORRECT_STATE             | CHIP_ERROR_INCORRECT_STATE          |
| INET_ERROR_MESSAGE_TOO_LONG            | CHIP_ERROR_MESSAGE_TOO_LONG         |
| INET_ERROR_NO_CONNECTION_HANDLER       | CHIP_ERROR_NO_CONNECTION_HANDLER    |
| INET_ERROR_NO_ENDPOINTS                | CHIP_ERROR_ENDPOINT_POOL_FULL       |
| INET_ERROR_NOT_IMPLEMENTED             | CHIP_ERROR_NOT_IMPLEMENTED          |
| INET_ERROR_NOT_SUPPORTED               | CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE |
| INET_ERROR_NO_MEMORY                   | CHIP_ERROR_NO_MEMORY                |
| INET_ERROR_CONNECTION_ABORTED          | CHIP_ERROR_CONNECTION_ABORTED       |

#### Testing

Modified some unit tests to account for consolidated error codes.

Built locally with `CHIP_ERROR` hardcoded to `int32_t`, `uint32_t`,
`int16_t`, and `uint16_t` to shake out mistaken type assumptions.

* Build fixes

* Darwin
* Doxygen

* Fixes

* Change default CHIP_CONFIG_ERROR_TYPE back to `int32_t`.
* Fix CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG message text.
* C++-style casts.

* fix: CHIPError.h uses stdint.h

* zap

* fix for Mbed merge
nikita-s-wrk pushed a commit to nikita-s-wrk/connectedhomeip that referenced this issue Sep 23, 2021
* add electrical measurement cluster to controller-clusters.zap

Only a selection of the optional clusters is enabled.

mandatory:
- measurement type

optional:
- total active power
- rms voltage
- rms voltage min
- rms voltage max
- rms current
- rms current min
- rms current max
- active power
- active power min
- active power max

* add electrical measurement cluster to zap_cluster_list.py

* add electrical measurement cluster to all-clusters-app

* add electrical measurement cluster to all-cluster-app/esp32

* add app helpers for electrical measurement cluster

* fix all cluster app build

* regen all

* Regenerating

* Restyled by whitespace

* Restyled by clang-format

* Regenerating

* Restyled by whitespace

* Restyled by google-java-format

* [fix] Wrong callback passed to WriteAttribute in Python[TE4] (project-chip#8019)

* Fix callback typr

* Run codegen

* Mdns: _chip* -> _matter*, remove 0's on subtypes (project-chip#7805)

* Mdns: _chip* i-> _matter*, remove 0's on subtypes

The second ballot changed the format of the subtypes as well as
fixed the service name prefix from _chip* to _matter*.

NOTE FOR DEVs: Updating past this change will require updating the
devices and controllers as otherwise they will be unable to find
each other.

* Darwin - use local kLocalDomain var.

It includes a . and the one in the ServiceNaming doesn't.

* Trying again for Darwin.

* Fix host name.

* Fix small error on merge

* Use a dedicated chip-types.xml file into src/app/zap-templates/zcl (project-chip#7873)

* Update chip-types.xml

* Update gen/ folders

* Revert "Mark UDP socket as ready for write in send msg. (project-chip#7927)" (project-chip#8027)

Turns out the code causes that subsequent select()-s never
wait so another solution for the original issue must be
prepared.

This reverts commit 8c55523.

* [ZAP] Add isAnalog instead of isDiscreteType to account for string types (project-chip#7821)

* Mdns: separate query responders for advertisers (project-chip#7615)

* Mdns: separate query responders for advertisers

The current setup uses a single query responder for commissionable
and operational and all the records are cleared together and added
in a large group. This makes it challenging to run commissionable
and operational at the same time since they can't be cleared
individually and because there are duplicate records between
operational and commissionable. This commit changes the code to
use one query responder per advertisement type and gets the
ResponseSender to loop through the query responders to filter
for answers.

* Apply suggestions from code review

Co-authored-by: chrisdecenzo <[email protected]>

* Restyled by clang-format

* Fix tests - they were not testing right.

* Restyled by clang-format

* Update number of responders

Represents 5 multi-admin fabrics for operational, commissionable
and commissioner.

* Whoops - broke a test with my last "minor" change.

* Lighten the stack load for the failing test.

Co-authored-by: chrisdecenzo <[email protected]>
Co-authored-by: Restyled.io <[email protected]>

* [nrfconnect] Stop using cooperative threads (project-chip#8025)

nRF Connect platform used cooperative threads, that is
threads that cannot be preempted, to workaround some
synchronization issues in the past, but it's no longer
needed and is risky. The latter was revealed by project-chip#7927,
which caused that `select()` never waits (needs to be
fixed in another PR).

Signed-off-by: Damian Krolik <[email protected]>

* IPV6-only test app for esp32 (examples/ipv6only-app) (project-chip#7289)

Adds RPCs that conform to NDM/GDM WiFi capabilities.
Disables IPV4 DHCP client. Assigns link-local IPV6 address.
Starts a UDP echo server on an IPV6 UDP socket.

Test: Ran on M5Stack and verified it scanned and connected to wifi,
after connected verified it echoed UDP messages.

* [ESP32] fix compile error for persistent-storage app (project-chip#7940)

* [ESP32] fix compile error for persistent-storage app

* add CI for all ESP examples

* Consolidate error types (project-chip#7916)

* Consolidate error types

#### Problem

CHIP currently has `CHIP_ERROR`, `INET_ERROR`, `BLE_ERROR`,
`ASN1_ERROR`, `System::Error`. Since they're all integers underneath,
there is no type checking, and existing code routinely treats them
as interchangeable. There is also existing code that uses `int` and
`int32_t`.  Each also has a `…_NO_ERROR` code which is independently
configurable, but existing code assumes they are equal, and there is
exising code that assumes the C convention that the value is 0.

#### Change overview

Fixes project-chip#7688 Unify chip errors

This change is largely a mechanical replacement of type and some error
code names, with a few cleanups of weak typing.

Consolidated error types to one, `CHIP_ERROR`.

Removed configurability of `CHIP_NO_ERROR`; it must be 0.

Added `CHIP_ERROR_FORMAT` to replace hardcoded `PRI…32` in `printf()`
format strings.

Added `CHIP_ERROR_SENTINEL` to replace the use of `CHIP_ERROR_MAX` as a
sentinel.

Renamed or consolidated the following errors, which have the same
meaning. Merely similar codes are left alone. This change contains
compatibility defintitions to avoid breaking PRs in flight, which
will be removed in a followup.

| before                                 | after                               |
|:---------------------------------------|:------------------------------------|
| ASN1_ERROR                             | CHIP_ERROR                          |
| ASN1_NO_ERROR                          | CHIP_NO_ERROR                       |
| BLE_ERROR                              | CHIP_ERROR                          |
| BLE_NO_ERROR                           | CHIP_NO_ERROR                       |
| BLE_ERROR_BAD_ARGS                     | CHIP_ERROR_INVALID_ARGUMENT         |
| BLE_ERROR_INCORRECT_STATE              | CHIP_ERROR_INCORRECT_STATE          |
| BLE_ERROR_MESSAGE_INCOMPLETE           | CHIP_ERROR_MESSAGE_INCOMPLETE       |
| BLE_ERROR_NOT_IMPLEMENTED              | CHIP_ERROR_NOT_IMPLEMENTED          |
| BLE_ERROR_NO_ENDPOINTS                 | CHIP_ERROR_ENDPOINT_POOL_FULL       |
| BLE_ERROR_NO_MEMORY                    | CHIP_ERROR_NO_MEMORY                |
| BLE_ERROR_OUTBOUND_MESSAGE_TOO_BIG     | CHIP_ERROR_OUTBOUND_MESSAGE_TOO_BIG |
| BLE_ERROR_RECEIVED_MESSAGE_TOO_BIG     | CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG  |
| CHIP_SYSTEM_NO_ERROR                   | CHIP_NO_ERROR                       |
| CHIP_SYSTEM_ERROR_ACCESS_DENIED        | CHIP_ERROR_ACCESS_DENIED            |
| CHIP_SYSTEM_ERROR_BAD_ARGS             | CHIP_ERROR_INVALID_ARGUMENT         |
| CHIP_SYSTEM_ERROR_NOT_SUPPORTED        | CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE |
| CHIP_SYSTEM_ERROR_NO_MEMORY            | CHIP_ERROR_NO_MEMORY                |
| CHIP_SYSTEM_ERROR_REAL_TIME_NOT_SYNCED | CHIP_ERROR_REAL_TIME_NOT_SYNCED     |
| CHIP_SYSTEM_ERROR_UNEXPECTED_EVENT     | CHIP_ERROR_UNEXPECTED_EVENT         |
| CHIP_SYSTEM_ERROR_UNEXPECTED_STATE     | CHIP_ERROR_INCORRECT_STATE          |
| INET_ERROR                             | CHIP_ERROR                          |
| INET_NO_ERROR                          | CHIP_NO_ERROR                       |
| INET_ERROR_BAD_ARGS                    | CHIP_ERROR_INVALID_ARGUMENT         |
| INET_ERROR_INBOUND_MESSAGE_TOO_BIG     | CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG  |
| INET_ERROR_INCORRECT_STATE             | CHIP_ERROR_INCORRECT_STATE          |
| INET_ERROR_MESSAGE_TOO_LONG            | CHIP_ERROR_MESSAGE_TOO_LONG         |
| INET_ERROR_NO_CONNECTION_HANDLER       | CHIP_ERROR_NO_CONNECTION_HANDLER    |
| INET_ERROR_NO_ENDPOINTS                | CHIP_ERROR_ENDPOINT_POOL_FULL       |
| INET_ERROR_NOT_IMPLEMENTED             | CHIP_ERROR_NOT_IMPLEMENTED          |
| INET_ERROR_NOT_SUPPORTED               | CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE |
| INET_ERROR_NO_MEMORY                   | CHIP_ERROR_NO_MEMORY                |
| INET_ERROR_CONNECTION_ABORTED          | CHIP_ERROR_CONNECTION_ABORTED       |

#### Testing

Modified some unit tests to account for consolidated error codes.

Built locally with `CHIP_ERROR` hardcoded to `int32_t`, `uint32_t`,
`int16_t`, and `uint16_t` to shake out mistaken type assumptions.

* Build fixes

* Darwin
* Doxygen

* Fixes

* Change default CHIP_CONFIG_ERROR_TYPE back to `int32_t`.
* Fix CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG message text.
* C++-style casts.

* fix: CHIPError.h uses stdint.h

* zap

* fix for Mbed merge

* Throw exception instead of return 0 for get-fabricid in case of error (project-chip#7884)

* Implement User Directed Commissioning - Phase 1 (project-chip#8034)

* Updated CHIP Certs Implementation to Use Spans instaed of Pointer/Len Pairs. (project-chip#7599)

Specifically, added the following FixedSpan types:
  - CertificateKeyId
  - P256ECDSASignatureSpan
  - P256PublicKeySpan
Also redefined mString member in the ChipRDN structure to be ByteSpan.

* Zap use const expr for clusters commands attributes (project-chip#7946)

* Remove duplicated command ids and attribute ids definitions from the encoder-src.zapt template

Add ids/Commands.zapt template

Update template to use Commands.h and Clusters.h

* Fix XML definitions typos for attributes name

* Add ids/Commands.h to the gen folder of src/app/common

* Update log messages for session expiry (project-chip#8017)

* Update log messages for session expiry

* update format specifier

* Remove client-command-macro.h-aa80d825 from examples/bridge-app/bridge-common/gen (project-chip#8026)

* Fix Ble endpoint pool FULL on macOS controller (project-chip#7806)

* * Move naming qpg6100 to qpg (project-chip#7936)

* Removal Env overrides sdk root and target IC

* fix build error in TCP.cpp (project-chip#8072)

Include <limits> to satisfy the proper use of std::numeric_limits.

* Add lighting example for Mbed OS (project-chip#8048)

* Add back structs, bitmaps and enums of the Messaging cluster into ami… (project-chip#8061)

* Add back structs, bitmaps and enums of the Messaging cluster into ami.xml

* Update gen/ folders

* Deprecated ASN1Writer::Finalize() Method. (project-chip#8056)

* Split KeyValueStoreManager.java into interface and impl, and add Set() in JNI. (project-chip#8046)

* [Test] Add Test_TC_DM_3_1 (project-chip#8067)

* Add Test_TC_DM_3_1 to src/app/tests/suites with all tests disabled since the attributes are not present into commissioning.xml

* Update generated tests

* Followup project-chip#7873 - Replace emberAfPutInt8uInResp(ZCL_DEFAULT_RESPONSE_COMMAND_ID) by emberAfPutInt32uInResp(ZCL_DEFAULT_RESPONSE_COMMAND_ID) in src/app/util/util.cpp (project-chip#8060)

* Remove call-command-handler.cpp from src/controller/data_model/gen/ and from src/darwin/Framework/CHIP.xcodeproj/project.pbxproj (project-chip#8021)

* Add PID to Darwin/Linux Log Lines (project-chip#7657)

* Add PID to Darwin/Linux Log Lines

Problem:
- Debugging test failures that involve multiple instances of
  applications is difficult when the log lines don't indicate which
  process/application they're coming from.

Solution:
- Added PID to the log lines on Darwin & Linux minimally to aid in
  debugging.

Testing:
- Ran chip-tool on both platforms.

* Restyled by clang-format

Co-authored-by: Restyled.io <[email protected]>

* Update Darwin framework to use GetConnectedDevice (project-chip#8011)

* Update Darwin framework to use GetConnectedDevice

* address review comments

* Add a string circular buffer. (project-chip#7475)

* Add a string circular buffer.

* Update src/lib/support/StringCircularBuffer.cpp

Co-authored-by: Boris Zbarsky <[email protected]>

* Update src/lib/support/StringCircularBuffer.cpp

Co-authored-by: Boris Zbarsky <[email protected]>

* Update src/lib/support/StringCircularBuffer.cpp

Co-authored-by: Boris Zbarsky <[email protected]>

* Resolve comments

* Resolve comments

* Resolve comments

* Resolve comments

Co-authored-by: Justin Wood <[email protected]>
Co-authored-by: Boris Zbarsky <[email protected]>

* [lighting-app] Enable optional Basic Cluster attributes (project-chip#8083)

* [lighting-app] Enable optional Basic Cluster attributes

Enable optional Basic Cluster attributes as requested by
Chaintanya, to verify a proper behaviour of the Python
controller.

* Re-gen code

* Add GenerateEventPathList and test (project-chip#8014)

Summary of Changes:
-- Add GenerateEventPathList function in ReadClinet
-- Add one event path test and two event path test
-- Fix im e2e cirque test in chip_im_responder from PR 7634 since cirque test is not
enabled

* Have a single loopback transport implementation for tests. (project-chip#8045)

We have multiple, some with different bells and whistles.  Should have one shared thing.

Unfortunately, some consumers want to drive things off the loopback
(like resending reliable messages) that other consumers can't know
about because they are at lower layers of the stack.  We just use a
virtual hook for that for now.

* Don't treat a resolve as done in chip-device-ctrl until we have a CASE connection. (project-chip#8012)

This ensures that following commands will work instead of racing the
CASE connection setup.

* Regenerating

* Restyled by whitespace

* Restyled by google-java-format

* Regenerating

Co-authored-by: Justin Wood <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Song Guo <[email protected]>
Co-authored-by: C Freeman <[email protected]>
Co-authored-by: Vivien Nicolas <[email protected]>
Co-authored-by: Damian Królik <[email protected]>
Co-authored-by: chrisdecenzo <[email protected]>
Co-authored-by: rgoliver <[email protected]>
Co-authored-by: Wang Qixiang <[email protected]>
Co-authored-by: Kevin Schoedel <[email protected]>
Co-authored-by: Yufeng Wang <[email protected]>
Co-authored-by: Evgeny Margolis <[email protected]>
Co-authored-by: Pankaj Garg <[email protected]>
Co-authored-by: krypton36 <[email protected]>
Co-authored-by: Timothy Maes <[email protected]>
Co-authored-by: CodeChronos <[email protected]>
Co-authored-by: Vincent Coubard <[email protected]>
Co-authored-by: Austin Hsieh <[email protected]>
Co-authored-by: Jerry Johns <[email protected]>
Co-authored-by: Zang MingJie <[email protected]>
Co-authored-by: Boris Zbarsky <[email protected]>
Co-authored-by: yunhanw-google <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant