mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-06-11 11:56:18 +00:00
add code_string to error event
This commit is contained in:
@@ -64,6 +64,15 @@ class EventType(Enum):
|
|||||||
CONNECTED = "connected"
|
CONNECTED = "connected"
|
||||||
DISCONNECTED = "disconnected"
|
DISCONNECTED = "disconnected"
|
||||||
|
|
||||||
|
# a dict to associate a message to an error code
|
||||||
|
ErrorMessages = {
|
||||||
|
1: "ERR_CODE_UNSUPPORTED_CMD",
|
||||||
|
2: "ERR_CODE_NOT_FOUND",
|
||||||
|
3: "ERR_CODE_TABLE_FULL",
|
||||||
|
4: "ERR_CODE_BAD_STATE",
|
||||||
|
5: "ERR_CODE_FILE_IO_ERROR",
|
||||||
|
6: "ERR_CODE_ILLEGAL_ARG",
|
||||||
|
}
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Event:
|
class Event:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import struct
|
|||||||
import time
|
import time
|
||||||
import io
|
import io
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
from .events import Event, EventType, EventDispatcher
|
from .events import Event, EventType, EventDispatcher, ErrorMessages
|
||||||
from .packets import BinaryReqType, PacketType, ControlType
|
from .packets import BinaryReqType, PacketType, ControlType
|
||||||
from .parsing import lpp_parse, lpp_parse_mma, parse_acl, parse_status
|
from .parsing import lpp_parse, lpp_parse_mma, parse_acl, parse_status
|
||||||
from cayennelpp import LppFrame, LppData
|
from cayennelpp import LppFrame, LppData
|
||||||
@@ -80,7 +80,10 @@ class MessageReader:
|
|||||||
|
|
||||||
elif packet_type_value == PacketType.ERROR.value:
|
elif packet_type_value == PacketType.ERROR.value:
|
||||||
if len(data) > 1:
|
if len(data) > 1:
|
||||||
result = {"error_code": data[1]}
|
result = {
|
||||||
|
"error_code": data[1],
|
||||||
|
"code_string": ErrorMessages[data[1]],
|
||||||
|
}
|
||||||
else:
|
else:
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user