diff --git a/lib/olt_lib/ir_rx/olt.py b/lib/olt_lib/ir_rx/olt.py index 6066ad4..cc84459 100644 --- a/lib/olt_lib/ir_rx/olt.py +++ b/lib/olt_lib/ir_rx/olt.py @@ -31,7 +31,7 @@ class SONY_ABC(IR_RX): # Abstract base class if nedges > 50: raise RuntimeError(self.OVERRUN) bits = (nedges - 2) // 2 - if nedges not in (26, 32, 42, 50) or bits > self._bits: + if nedges not in (58, 30, 50) or bits > self._bits: raise RuntimeError(self.BADBLOCK) self.verbose and print("SIRC {}bit".format(bits)) width = ticks_diff(self._times[1], self._times[0]) diff --git a/main.py b/main.py index d901048..aa0fe72 100644 --- a/main.py +++ b/main.py @@ -2,7 +2,7 @@ # OLT protocol. # Tomas Krejci [Njord] -import machine, time +import machine, time, re from sys import platform ESP32 = platform == "esp32" @@ -14,10 +14,14 @@ else: from pyb import Pin, LED import uasyncio as asyncio -device_id = "" +#### Device ID ### +device_id_str = "" for b in machine.unique_id(): - device_id += "{:02X}".format(b) -# device_id_hex = int(device_id) + device_id_str += "{:02X}".format(b) + +device_id_str = device_id_str[-4:] # Keep last 8 char +device_id = int(device_id_str, 16) # Convert to int from hex in string +# device_id_str = str(device_id, 16) # Convert back to hex print(f"{device_id:0x}") #### BLE UART ### import ble_uart @@ -30,7 +34,7 @@ def print_handler(): ble = bluetooth.BLE() -uart = ble_uart.Ble_uart(ble, on_rx=print_handler, name=print("LaserTag")) +uart = ble_uart.Ble_uart(ble, on_rx=print_handler, name="OpenLaserTag " + device_id_str) #### OLT IR RX imports ### import ustruct @@ -155,7 +159,7 @@ async def cb(byte1, byte2, byte3, packet): async def main(proto): logger.debug("main start") - print(f"Device ID: {device_id}") + print(f"Device ID: {device_id_str}") ### alive check ### asyncio.create_task(alive_check())