Merge pull request #652 from ianmcorvidae/randomized-packet-ids

randomize packet IDs as firmware does
This commit is contained in:
Ben Meadors authored and GitHub committed 2024-08-23 17:30:07 -05:00
commit 1abe00d0b2
1 file changed
+4 -1
+4 -1
View File
@@ -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):