mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-06-14 13:16:54 +00:00
support manual add contact
This commit is contained in:
@@ -313,6 +313,9 @@ class CommandHandler:
|
|||||||
+ int(contact["adv_lon"]*1e6).to_bytes(4, 'little', signed=True)
|
+ int(contact["adv_lon"]*1e6).to_bytes(4, 'little', signed=True)
|
||||||
return await self.send(data, [EventType.OK, EventType.ERROR])
|
return await self.send(data, [EventType.OK, EventType.ERROR])
|
||||||
|
|
||||||
|
async def add_contact (self, contact) -> Event:
|
||||||
|
return await self.update_contact(contact)
|
||||||
|
|
||||||
async def change_contact_path (self, contact, path) -> Event:
|
async def change_contact_path (self, contact, path) -> Event:
|
||||||
return await self.update_contact(contact, path)
|
return await self.update_contact(contact, path)
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class EventType(Enum):
|
|||||||
DEVICE_INFO = "device_info"
|
DEVICE_INFO = "device_info"
|
||||||
CLI_RESPONSE = "cli_response"
|
CLI_RESPONSE = "cli_response"
|
||||||
MSG_SENT = "message_sent"
|
MSG_SENT = "message_sent"
|
||||||
|
NEW_CONTACT = "new_contact"
|
||||||
|
|
||||||
# Push notifications
|
# Push notifications
|
||||||
ADVERTISEMENT = "advertisement"
|
ADVERTISEMENT = "advertisement"
|
||||||
|
|||||||
@@ -99,7 +99,8 @@ class MessageReader:
|
|||||||
|
|
||||||
await self.dispatcher.dispatch(Event(EventType.MSG_SENT, res, attributes))
|
await self.dispatcher.dispatch(Event(EventType.MSG_SENT, res, attributes))
|
||||||
|
|
||||||
elif packet_type_value == PacketType.CONTACT_MSG_RECV.value:
|
elif packet_type_value == PacketType.CONTACT_MSG_RECV.value or\
|
||||||
|
packet_type_value == PacketType.PUSH_CODE_NEW_ADVERT.value:
|
||||||
res = {}
|
res = {}
|
||||||
res["type"] = "PRIV"
|
res["type"] = "PRIV"
|
||||||
res["pubkey_prefix"] = data[1:7].hex()
|
res["pubkey_prefix"] = data[1:7].hex()
|
||||||
@@ -117,7 +118,11 @@ class MessageReader:
|
|||||||
"txt_type": res["txt_type"]
|
"txt_type": res["txt_type"]
|
||||||
}
|
}
|
||||||
|
|
||||||
await self.dispatcher.dispatch(Event(EventType.CONTACT_MSG_RECV, res, attributes))
|
evt_type = EventType.CONTACT_MSG_RECV
|
||||||
|
if packet_type_value == PacketType.PUSH_CODE_NEW_ADVERT.value :
|
||||||
|
evt_type = EventType.NEW_CONTACT
|
||||||
|
|
||||||
|
await self.dispatcher.dispatch(Event(evt_type, res, attributes))
|
||||||
|
|
||||||
elif packet_type_value == 16: # A reply to CMD_SYNC_NEXT_MESSAGE (ver >= 3)
|
elif packet_type_value == 16: # A reply to CMD_SYNC_NEXT_MESSAGE (ver >= 3)
|
||||||
res = {}
|
res = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user