move tx logic to main loop from IRQ