mirror of
https://github.com/meshtastic/python.git
synced 2026-01-16 19:58:04 -05:00
Merge pull request #652 from ianmcorvidae/randomized-packet-ids
randomize packet IDs as firmware does
This commit is contained in:
@@ -802,7 +802,10 @@ class MeshInterface: # pylint: disable=R0902
|
||||
"Not connected yet, can not generate packet"
|
||||
)
|
||||
else:
|
||||
self.currentPacketId = (self.currentPacketId + 1) & 0xFFFFFFFF
|
||||
nextPacketId = (self.currentPacketId + 1) & 0xFFFFFFFF
|
||||
nextPacketId = nextPacketId & (0xFFFFFFFF >> 22) # mask upper 22 bits
|
||||
randomPart = (random.randint(0, 0x7FFFFFFF) << 10) & 0xFFFFFFFF # generate number with 10 zeros at end
|
||||
self.currentPacketId = nextPacketId | randomPart # combine
|
||||
return self.currentPacketId
|
||||
|
||||
def _disconnected(self):
|
||||
|
||||
Reference in New Issue
Block a user