diff --git a/lib/audio_files/beep.mp3 b/lib/audio_files/beep.mp3 deleted file mode 100644 index a8f7e59..0000000 Binary files a/lib/audio_files/beep.mp3 and /dev/null differ diff --git a/lib/audio_files/test.mp3 b/lib/audio_files/test.mp3 deleted file mode 100644 index 1a96427..0000000 Binary files a/lib/audio_files/test.mp3 and /dev/null differ diff --git a/lib/audio_files/test.wav b/lib/audio_files/test.wav deleted file mode 100644 index 1e18020..0000000 Binary files a/lib/audio_files/test.wav and /dev/null differ diff --git a/lib/ble_uart/__init__.py b/lib/ble_uart/__init__.py index a895251..e956350 100644 --- a/lib/ble_uart/__init__.py +++ b/lib/ble_uart/__init__.py @@ -1,6 +1,6 @@ import bluetooth from ble_uart.ble_advertising import advertising_payload - +import uasyncio as asyncio from micropython import const _IRQ_CENTRAL_CONNECT = const(1) @@ -67,7 +67,7 @@ class Ble_uart: if conn_handle in self._connections and value_handle == self._rx_handle: self._rx_buffer += self._ble.gatts_read(self._rx_handle) if self._handler: - self._handler() + asyncio.create_task(self._handler()) def any(self): return len(self._rx_buffer) diff --git a/main.py b/main.py index 55d3fc0..2a8fc9b 100644 --- a/main.py +++ b/main.py @@ -84,16 +84,25 @@ import bluetooth import time -def ble_rx_handler(): +async def ble_rx_handler(): message = uart.read().decode().strip() - logger.debug(f"BLE: {message}") + logger.debug(f"BLE: {message}") try: if "bomb" in message: - logger.info("BLE: Bomb Explode send to IR") - asyncio.create_task( - olt_sent_ir(ir_tx, COMMANDS[1][1], COMMANDS[1][2], COMMANDS[1][3]) - ) + logger.info("BLE: Bomb Explode send to IR") + asyncio.create_task( + olt_sent_ir(ir_tx, COMMANDS[1][1], COMMANDS[1][2], COMMANDS[1][3]) + ) + uart.write("BLE: Bomb Explode send to IR\n") + while True: + time.sleep_ms(2000) + logger.info( + "BLE: Bomb Exploded, Device is LOCKED, please restart Device" + ) + uart.write( + "BLE: Bomb Exploded, Device is LOCKED\n Please restart Device\n" + ) message_int = int(message, 16) logger.debug(f"BLE: {message_int:08x}")