mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
manual add contacts
This commit is contained in:
parent
f4a4c5cfd0
commit
460196a754
2 changed files with 12 additions and 10 deletions
|
|
@ -208,7 +208,7 @@ class CommandHandler:
|
|||
telemetry_mode_base,
|
||||
infos["telemetry_mode_loc"],
|
||||
infos["telemetry_mode_env"],
|
||||
infos["advert_loc_policy"])
|
||||
infos["adv_loc_policy"])
|
||||
|
||||
async def set_telemetry_mode_loc(self, telemetry_mode_loc : int) :
|
||||
infos = (await self.send_appstart()).payload
|
||||
|
|
@ -217,7 +217,7 @@ class CommandHandler:
|
|||
infos["telemetry_mode_base"],
|
||||
telemetry_mode_loc,
|
||||
infos["telemetry_mode_env"],
|
||||
infos["advert_loc_policy"])
|
||||
infos["adv_loc_policy"])
|
||||
|
||||
async def set_telemetry_mode_env(self, telemetry_mode_env : int) :
|
||||
infos = (await self.send_appstart()).payload
|
||||
|
|
@ -226,7 +226,7 @@ class CommandHandler:
|
|||
infos["telemetry_mode_base"],
|
||||
infos["telemetry_mode_loc"],
|
||||
telemetry_mode_env,
|
||||
infos["advert_loc_policy"])
|
||||
infos["adv_loc_policy"])
|
||||
|
||||
async def set_manual_add_contacts(self, manual_add_contacts:bool) :
|
||||
infos = (await self.send_appstart()).payload
|
||||
|
|
@ -235,7 +235,7 @@ class CommandHandler:
|
|||
infos["telemetry_mode_base"],
|
||||
infos["telemetry_mode_loc"],
|
||||
infos["telemetry_mode_env"],
|
||||
infos["advert_loc_policy"])
|
||||
infos["adv_loc_policy"])
|
||||
|
||||
async def set_advert_loc_policy(self, advert_loc_policy:int) :
|
||||
infos = (await self.send_appstart()).payload
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@ class MessageReader:
|
|||
self.contact_nb = int.from_bytes(data[1:5], byteorder='little')
|
||||
self.contacts = {}
|
||||
|
||||
elif packet_type_value == PacketType.CONTACT.value:
|
||||
elif packet_type_value == PacketType.CONTACT.value or\
|
||||
packet_type_value == PacketType.PUSH_CODE_NEW_ADVERT.value:
|
||||
c = {}
|
||||
c["public_key"] = data[1:33].hex()
|
||||
c["type"] = data[33]
|
||||
|
|
@ -60,7 +61,11 @@ class MessageReader:
|
|||
c["adv_lat"] = int.from_bytes(data[136:140], byteorder='little',signed=True)/1e6
|
||||
c["adv_lon"] = int.from_bytes(data[140:144], byteorder='little',signed=True)/1e6
|
||||
c["lastmod"] = int.from_bytes(data[144:148], byteorder='little')
|
||||
self.contacts[c["public_key"]] = c
|
||||
|
||||
if packet_type_value == PacketType.PUSH_CODE_NEW_ADVERT.value :
|
||||
await self.dispatcher.dispatch(Event(EventType.NEW_CONTACT, c))
|
||||
else:
|
||||
self.contacts[c["public_key"]] = c
|
||||
|
||||
elif packet_type_value == PacketType.CONTACT_END.value:
|
||||
await self.dispatcher.dispatch(Event(EventType.CONTACTS, self.contacts))
|
||||
|
|
@ -98,8 +103,7 @@ class MessageReader:
|
|||
|
||||
await self.dispatcher.dispatch(Event(EventType.MSG_SENT, res, attributes))
|
||||
|
||||
elif packet_type_value == PacketType.CONTACT_MSG_RECV.value or\
|
||||
packet_type_value == PacketType.PUSH_CODE_NEW_ADVERT.value:
|
||||
elif packet_type_value == PacketType.CONTACT_MSG_RECV.value:
|
||||
res = {}
|
||||
res["type"] = "PRIV"
|
||||
res["pubkey_prefix"] = data[1:7].hex()
|
||||
|
|
@ -118,8 +122,6 @@ class MessageReader:
|
|||
}
|
||||
|
||||
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))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue