mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
some fixes in return events
This commit is contained in:
parent
dd908484f7
commit
d61720fc9f
7 changed files with 10 additions and 10 deletions
BIN
dist/meshcore-1.9.2-py3-none-any.whl
vendored
Normal file
BIN
dist/meshcore-1.9.2-py3-none-any.whl
vendored
Normal file
Binary file not shown.
BIN
dist/meshcore-1.9.2.tar.gz
vendored
Normal file
BIN
dist/meshcore-1.9.2.tar.gz
vendored
Normal file
Binary file not shown.
|
|
@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|||
|
||||
[project]
|
||||
name = "meshcore"
|
||||
version = "1.9.1"
|
||||
version = "1.9.3"
|
||||
authors = [
|
||||
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
|
||||
{ name="Alex Wolden", email="awolden@gmail.com" },
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ class CommandHandler:
|
|||
key_bytes = _validate_destination(key, prefix_length=32)
|
||||
logger.debug(f"Sharing contact: {key_bytes.hex()}")
|
||||
data = b"\x10" + key_bytes
|
||||
return await self.send(data, [EventType.CONTACT_SHARE, EventType.ERROR])
|
||||
return await self.send(data, [EventType.OK, EventType.ERROR])
|
||||
|
||||
async def export_contact(self, key: Optional[DestinationType] = None) -> Event:
|
||||
if key:
|
||||
|
|
@ -223,9 +223,9 @@ class CommandHandler:
|
|||
logger.debug(f"Exporting contact: {key_bytes.hex()}")
|
||||
data = b"\x11" + key_bytes
|
||||
else:
|
||||
logger.debug("Exporting all contacts")
|
||||
logger.debug("Exporting node")
|
||||
data = b"\x11"
|
||||
return await self.send(data, [EventType.OK, EventType.ERROR])
|
||||
return await self.send(data, [EventType.CONTACT_URI, EventType.ERROR])
|
||||
|
||||
async def remove_contact(self, key: DestinationType) -> Event:
|
||||
key_bytes = _validate_destination(key, prefix_length=32)
|
||||
|
|
@ -253,7 +253,7 @@ class CommandHandler:
|
|||
|
||||
async def get_msg(self, timeout: Optional[float] = 1) -> Event:
|
||||
logger.debug("Requesting pending messages")
|
||||
return await self.send(b"\x0A", [EventType.CONTACT_MSG_RECV, EventType.CHANNEL_MSG_RECV, EventType.ERROR], timeout)
|
||||
return await self.send(b"\x0A", [EventType.CONTACT_MSG_RECV, EventType.CHANNEL_MSG_RECV, EventType.ERROR, EventType.NO_MORE_MSGS], timeout)
|
||||
|
||||
async def send_login(self, dst: DestinationType, pwd: str) -> Event:
|
||||
dst_bytes = _validate_destination(dst, prefix_length=32)
|
||||
|
|
@ -282,7 +282,7 @@ class CommandHandler:
|
|||
timestamp = int(time.time())
|
||||
|
||||
data = b"\x02\x01\x00" + timestamp.to_bytes(4, 'little') + dst_bytes + cmd.encode("ascii")
|
||||
return await self.send(data, [EventType.OK, EventType.ERROR])
|
||||
return await self.send(data, [EventType.MSG_SENT, EventType.ERROR])
|
||||
|
||||
async def send_msg(self, dst: DestinationType, msg: str, timestamp: Optional[int] = None) -> Event:
|
||||
dst_bytes = _validate_destination(dst)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class EventType(Enum):
|
|||
CHANNEL_MSG_RECV = "channel_message"
|
||||
CURRENT_TIME = "time_update"
|
||||
NO_MORE_MSGS = "no_more_messages"
|
||||
CONTACT_SHARE = "contact_share"
|
||||
CONTACT_URI = "contact_uri"
|
||||
BATTERY = "battery_info"
|
||||
DEVICE_INFO = "device_info"
|
||||
CLI_RESPONSE = "cli_response"
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class PacketType(Enum):
|
|||
CHANNEL_MSG_RECV = 8
|
||||
CURRENT_TIME = 9
|
||||
NO_MORE_MSGS = 10
|
||||
CONTACT_SHARE = 11
|
||||
CONTACT_URI = 11
|
||||
BATTERY = 12
|
||||
DEVICE_INFO = 13
|
||||
CLI_RESPONSE = 50
|
||||
|
|
|
|||
|
|
@ -174,10 +174,10 @@ class MessageReader:
|
|||
result = {"messages_available": False}
|
||||
await self.dispatcher.dispatch(Event(EventType.NO_MORE_MSGS, result))
|
||||
|
||||
elif packet_type_value == PacketType.CONTACT_SHARE.value:
|
||||
elif packet_type_value == PacketType.CONTACT_URI.value:
|
||||
contact_uri = "meshcore://" + data[1:].hex()
|
||||
result = {"uri": contact_uri}
|
||||
await self.dispatcher.dispatch(Event(EventType.CONTACT_SHARE, result))
|
||||
await self.dispatcher.dispatch(Event(EventType.CONTACT_URI, result))
|
||||
|
||||
elif packet_type_value == PacketType.BATTERY.value:
|
||||
battery_level = int.from_bytes(data[1:3], byteorder='little')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue