Add esp ble error code mappings (#292)

This commit is contained in:
J. Nick Koston 2022-10-29 04:43:55 -05:00 committed by GitHub
parent 483b1122a3
commit d4c44a3ccf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 0 deletions

View File

@ -1,4 +1,5 @@
# flake8: noqa
from .ble_defs import ESP_CONNECTION_ERROR_DESCRIPTION, BLEConnectionError
from .client import APIClient
from .connection import APIConnection, ConnectionParams
from .core import (

30
aioesphomeapi/ble_defs.py Normal file
View File

@ -0,0 +1,30 @@
from __future__ import annotations
from enum import IntEnum
class BLEConnectionError(IntEnum):
"""BLE Connection Error."""
ESP_GATT_CONN_UNKNOWN = 0
ESP_GATT_CONN_L2C_FAILURE = 1
ESP_GATT_CONN_TIMEOUT = 0x08
ESP_GATT_CONN_TERMINATE_PEER_USER = 0x13
ESP_GATT_CONN_TERMINATE_LOCAL_HOST = 0x16
ESP_GATT_CONN_FAIL_ESTABLISH = 0x3E
ESP_GATT_CONN_LMP_TIMEOUT = 0x22
ESP_GATT_CONN_CONN_CANCEL = 0x0100
ESP_GATT_CONN_NONE = 0x0101
ESP_CONNECTION_ERROR_DESCRIPTION = {
BLEConnectionError.ESP_GATT_CONN_UNKNOWN: "Connection failed for unknown reason",
BLEConnectionError.ESP_GATT_CONN_L2C_FAILURE: "Connection failed due to L2CAP failure",
BLEConnectionError.ESP_GATT_CONN_TIMEOUT: "Connection failed due to timeout",
BLEConnectionError.ESP_GATT_CONN_TERMINATE_PEER_USER: "Connection terminated by peer user",
BLEConnectionError.ESP_GATT_CONN_TERMINATE_LOCAL_HOST: "Connection terminated by local host",
BLEConnectionError.ESP_GATT_CONN_FAIL_ESTABLISH: "Connection failed to establish",
BLEConnectionError.ESP_GATT_CONN_LMP_TIMEOUT: "Connection failed due to LMP response timeout",
BLEConnectionError.ESP_GATT_CONN_CONN_CANCEL: "Connection cancelled",
BLEConnectionError.ESP_GATT_CONN_NONE: "No connection to cancel",
}