added basic cryptography, advertising, and forwarding functionality to the LoRa handler. Also added a UUID class for generating unique IDs for each device.

also, i have 2 radios now! :D
This commit is contained in:
2026-05-15 10:24:49 +10:00
parent 8abf447d66
commit 6f8083fdc2
8 changed files with 201 additions and 55 deletions

22
relay/uuid.py Normal file
View File

@@ -0,0 +1,22 @@
import urandom
def uuid4():
b = bytearray(urandom.getrandbits(8) for _ in range(16))
# Set version (4) -> bits 12-15 of time_hi_and_version
b[6] = (b[6] & 0x0F) | 0x40
# Set variant (RFC 4122)
b[8] = (b[8] & 0x3F) | 0x80
def to_hex(x):
return '{:02x}'.format(x)
return (
to_hex(b[0]) + to_hex(b[1]) + to_hex(b[2]) + to_hex(b[3]) + '-' +
to_hex(b[4]) + to_hex(b[5]) + '-' +
to_hex(b[6]) + to_hex(b[7]) + '-' +
to_hex(b[8]) + to_hex(b[9]) + '-' +
to_hex(b[10]) + to_hex(b[11]) + to_hex(b[12]) +
to_hex(b[13]) + to_hex(b[14]) + to_hex(b[15])
)