from BLE UART to custom IR TX
This commit is contained in:
parent
772244153e
commit
bf810ad31b
14
main.py
14
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):
|
||||
|
Loading…
Reference in New Issue
Block a user