From bf810ad31baff788d9f647a9a5369ce245131122 Mon Sep 17 00:00:00 2001 From: Tomas Krejci Date: Thu, 6 Jun 2024 16:36:01 +0200 Subject: [PATCH] from BLE UART to custom IR TX --- main.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 2a8fc9b..3090c26 100644 --- a/main.py +++ b/main.py @@ -107,10 +107,14 @@ async def ble_rx_handler(): message_int = int(message, 16) logger.debug(f"BLE: {message_int:08x}") - if message_int == 0x01: - uart.write(f"BLE: uart recive {message_int:08x}\n") - else: - logger.info(f"BLE: message is {message_int}") + ## if recive from BLE UART any hex number senend it as custom command to IR + tx1 = (message_int >> 16) & 0xFF + tx2 = (message_int >> 8) & 0xFF + tx3 = message_int & 0xFF + asyncio.create_task(olt_sent_ir(ir_tx, tx1, tx2, tx3)) + + ## send info back to BLE + uart.write(f"BLE: uart recive 0x{message_int:08x}\n") except TypeError: logger.debug("BLE: TypeError") @@ -219,7 +223,7 @@ async def olt_sent_ir(ir_tx, tx1, tx2, tx3): # IR TX send logger.debug(f"Command IR TX transmit") asyncio.create_task(ir_tx.transmit(tx1, tx2, tx3, False)) - await asyncio.sleep_ms(50) + await asyncio.sleep_ms(10) async def olt_command(cmd, btn, rgb, ir_tx, tx1, tx2, tx3):