diff --git a/dist/meshcore-1.9.2-py3-none-any.whl b/dist/meshcore-1.9.2-py3-none-any.whl new file mode 100644 index 0000000..2db91e6 Binary files /dev/null and b/dist/meshcore-1.9.2-py3-none-any.whl differ diff --git a/dist/meshcore-1.9.2.tar.gz b/dist/meshcore-1.9.2.tar.gz new file mode 100644 index 0000000..8ed516a Binary files /dev/null and b/dist/meshcore-1.9.2.tar.gz differ diff --git a/pyproject.toml b/pyproject.toml index 084ff8d..a120b37 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" }, diff --git a/src/meshcore/commands.py b/src/meshcore/commands.py index 729533d..4e034ef 100644 --- a/src/meshcore/commands.py +++ b/src/meshcore/commands.py @@ -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) diff --git a/src/meshcore/events.py b/src/meshcore/events.py index 345dd61..dabe789 100644 --- a/src/meshcore/events.py +++ b/src/meshcore/events.py @@ -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" diff --git a/src/meshcore/packets.py b/src/meshcore/packets.py index 6797489..a0166b5 100644 --- a/src/meshcore/packets.py +++ b/src/meshcore/packets.py @@ -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 diff --git a/src/meshcore/reader.py b/src/meshcore/reader.py index 23289f0..0ceda6d 100644 --- a/src/meshcore/reader.py +++ b/src/meshcore/reader.py @@ -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')