mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
support manual add contact
This commit is contained in:
parent
29ce8ec6d6
commit
0e54a624f1
3 changed files with 11 additions and 2 deletions
|
|
@ -313,6 +313,9 @@ class CommandHandler:
|
|||
+ int(contact["adv_lon"]*1e6).to_bytes(4, 'little', signed=True)
|
||||
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:
|
||||
return await self.update_contact(contact, path)
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ class EventType(Enum):
|
|||
DEVICE_INFO = "device_info"
|
||||
CLI_RESPONSE = "cli_response"
|
||||
MSG_SENT = "message_sent"
|
||||
NEW_CONTACT = "new_contact"
|
||||
|
||||
# Push notifications
|
||||
ADVERTISEMENT = "advertisement"
|
||||
|
|
|
|||
|
|
@ -99,7 +99,8 @@ class MessageReader:
|
|||
|
||||
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["type"] = "PRIV"
|
||||
res["pubkey_prefix"] = data[1:7].hex()
|
||||
|
|
@ -117,7 +118,11 @@ class MessageReader:
|
|||
"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)
|
||||
res = {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue