mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
add code_string to error event
This commit is contained in:
parent
462c4311d3
commit
fe2239a8c6
2 changed files with 14 additions and 2 deletions
|
|
@ -64,6 +64,15 @@ class EventType(Enum):
|
|||
CONNECTED = "connected"
|
||||
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
|
||||
class Event:
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import struct
|
|||
import time
|
||||
import io
|
||||
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 .parsing import lpp_parse, lpp_parse_mma, parse_acl, parse_status
|
||||
from cayennelpp import LppFrame, LppData
|
||||
|
|
@ -80,7 +80,10 @@ class MessageReader:
|
|||
|
||||
elif packet_type_value == PacketType.ERROR.value:
|
||||
if len(data) > 1:
|
||||
result = {"error_code": data[1]}
|
||||
result = {
|
||||
"error_code": data[1],
|
||||
"code_string": ErrorMessages[data[1]],
|
||||
}
|
||||
else:
|
||||
result = {}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue