]> git.aero2k.de Git - sirius.git/commitdiff
add hardware_address_xor
authorMatt Webb <matt@interconnected.org>
Mon, 22 Sep 2014 20:10:04 +0000 (21:10 +0100)
committerMatt Webb <matt@interconnected.org>
Mon, 22 Sep 2014 20:10:04 +0000 (21:10 +0100)
app/claiming.py
app/image_encoding.py

index 95ad76815f16c55047bcc14abb6b3a2066694848..a2a18a19a17f3d4cffdc8e4936f1f6901ee4c590 100755 (executable)
@@ -147,6 +147,20 @@ def process_claim_code(claim_code):
     
     return (hardware_address_xor, link_key_b64)
 
+def make_hardware_address_xor(device_address):
+    # the hardware_address_xor from device_address 000d6f000273ce0b
+    # should match the hardware_address_xor from claim_code
+    # ps2f-gsjg-8wsq-7hc4
+    b = bytearray.fromhex(device_address)
+    
+    claim_address = bytearray(3)
+    claim_address[0] = b[0] ^ b[5]
+    claim_address[1] = b[1] ^ b[3] ^ b[6]
+    claim_address[2] = b[2] ^ b[4] ^ b[7]
+    
+    result = claim_address[2] << 16 | claim_address[1] << 8 | claim_address[0]
+    
+    return result
 
 # ~~~~
 # Test
index b66c6084a993787fbabfeebd168134ffce88b5a2..3a9f36ad1204a9b899a56b252a52d055ee56f0bd 100644 (file)
@@ -1,6 +1,5 @@
 from PIL import Image
 from itertools import groupby
-import array
 import struct
 
 WHITE = 0
@@ -73,6 +72,8 @@ def rle_image(image_fn):
     lengths = [g[1] for g in groups]
     x = bytearray(rle(lengths))
     compressed_data = struct.pack("<%dB" % len(x), *x)
+    
+    # package up with length as header
     # first byte is compressed type, always 1
     output = struct.pack("<BL", 0x01, len(compressed_data)) + compressed_data
 
@@ -94,7 +95,7 @@ if __name__ == '__main__':
     for length, code in TRANSLATE:
         length_codes[code] = length
     
-    for b in rle_encoded:
+    for b in rle_encoded[3:]: # jump the header bytes
         length = ord(b)
         if length in length_codes.keys():
             length = length_codes[length]