diff --git a/epicardium/ble/uart.c b/epicardium/ble/uart.c
index 8fbe737db7ebc8710b74cc3a2618abd7b86e1db4..31575fa5f99e78fc5bf1041be343fe6788df4276 100644
--- a/epicardium/ble/uart.c
+++ b/epicardium/ble/uart.c
@@ -1,10 +1,13 @@
 #include "uart.h"
+#include "cccd.h"
 
 #include "modules/modules.h"
 
 #include "wsf_types.h"
 #include "util/bstream.h"
 #include "att_api.h"
+#include "dm_api.h"
+#include "app_api.h"
 
 #include "FreeRTOS.h"
 #include "timers.h"
@@ -99,8 +102,6 @@ static const attsAttr_t uartAttrCfgList[] = {
 
 };
 
-dmConnId_t active_connection = 0;
-
 static uint8_t UARTWriteCback(
 	dmConnId_t connId,
 	uint16_t handle,
@@ -110,7 +111,6 @@ static uint8_t UARTWriteCback(
 	uint8_t *pValue,
 	attsAttr_t *pAttr
 ) {
-	active_connection = connId;
 	static bool was_r = false;
 
 	int i;
@@ -129,27 +129,32 @@ static int ble_uart_lasttick = 0;
 
 void ble_uart_flush(void)
 {
-	if (ble_uart_buf_tx_fill > 0) {
-		if (active_connection) {
+	if (ble_uart_buf_tx_fill == 0) {
+		return;
+	}
+
+	dmConnId_t connId = AppConnIsOpen();
+	if (connId != DM_CONN_ID_NONE) {
+		if (AttsCccEnabled(connId, UART_TX_CH_CCC_IDX)) {
 			int x = xTaskGetTickCount() - ble_uart_lasttick;
 			if (x < 100) {
 				/*
-				 * TODO: Ugly hack if we already
-				 * sent something recently.
-				 * Use ATTS_HANDLE_VALUE_CNF instead.
-				 */
+					* TODO: Ugly hack if we already
+					* sent something recently.
+					* Use ATTS_HANDLE_VALUE_CNF instead.
+					*/
 				vTaskDelay(100 - x);
 			}
 			AttsHandleValueNtf(
-				active_connection,
+				connId,
 				UART_TX_HDL,
 				ble_uart_buf_tx_fill,
 				ble_uart_tx_buf
 			);
 			ble_uart_lasttick = xTaskGetTickCount();
 		}
-		ble_uart_buf_tx_fill = 0;
 	}
+	ble_uart_buf_tx_fill = 0;
 }
 
 void ble_uart_write_char(uint8_t c)
@@ -185,3 +190,14 @@ void bleuart_init(void)
 	/* Add the UART service */
 	AttsAddGroup(&uartCfgGroup);
 }
+
+void UartProcMsg(wsfMsgHdr_t *pMsg)
+{
+	if (pMsg->event == ATTS_HANDLE_VALUE_CNF) {
+		if (pMsg->status == ATT_SUCCESS) {
+		}
+	}
+	if (pMsg->event == DM_CONN_OPEN_IND) {
+		ble_uart_buf_tx_fill = 0;
+	}
+}