diff --git a/epicardium/ble/ble.c b/epicardium/ble/ble.c
index 9fc6c1523d4f9ab25a66545ae49bd8c16753e563..361b828ca875a933e7aa67087c79e14398d79114 100644
--- a/epicardium/ble/ble.c
+++ b/epicardium/ble/ble.c
@@ -12,6 +12,7 @@
 #include "FreeRTOS.h"
 #include "timers.h"
 
+#include <machine/endian.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdbool.h>
@@ -44,6 +45,8 @@ static StaticTimer_t x;
 static TimerHandle_t timerWakeup = NULL;
 static int lasttick              = 0;
 
+static int log_fd;
+
 /*! \brief  Stack initialization for app. */
 extern void StackInit(void);
 extern void AppInit(void);
@@ -70,6 +73,57 @@ static bool_t myTrace(const uint8_t *pBuf, uint32_t len)
 
 	return FALSE;
 }
+struct packet_header {
+	uint32_t original_length;
+	uint32_t included_length;
+	uint32_t packet_flags;
+	uint32_t cumulative_drops;
+	uint32_t timestamp_us_h;
+	uint32_t timestamp_us_l;
+};
+
+void WsfPDump(wsfPDumpType_t pdType, uint16_t length, uint8_t *pBuffer)
+{
+	uint32_t direction;
+	uint8_t type;
+
+	switch(pdType) {
+		case WSF_PDUMP_TYPE_HCI_CMD:
+			direction = 0;
+			type = 0x01;
+		break;
+		case WSF_PDUMP_TYPE_HCI_EVT:
+			direction = 1;
+			type = 0x04;
+		break;
+		case WSF_PDUMP_TYPE_HCI_TX_ACL:
+			direction = 0;
+			type = 0x02;
+		break;
+		case WSF_PDUMP_TYPE_HCI_RX_ACL:
+			direction = 1;
+			type = 0x02;
+		break;
+		default:
+		break;
+	}
+
+	int tick = xTaskGetTickCount();
+	uint64_t timestamp_us = tick * 1000;
+
+	struct packet_header header = {
+		.original_length = __htonl(length+1),
+		.included_length = __htonl(length+1),
+		.packet_flags = __htonl(direction),
+		.cumulative_drops = __htonl(0),
+		.timestamp_us_h = __htonl(timestamp_us >> 32),
+		.timestamp_us_l = __htonl(timestamp_us & 0xFFFFFFFF)
+	};
+
+	epic_file_write(log_fd, &header, sizeof(header));
+	epic_file_write(log_fd, &type, sizeof(type));
+	epic_file_write(log_fd, pBuffer, length);
+}
 /*************************************************************************************************/
 static void WsfInit(void)
 {
@@ -238,6 +292,13 @@ static void scheduleTimer(void)
 		APP_TRACE_INFO0("No timer running");
 	}
 }
+static const uint8_t log_header[] = {'b', 't', 's', 'n', 'o', 'o', 'p', 0, 0, 0, 0, 1, 0, 0, 0x03, 0xea};
+
+void ble_log_flush(void)
+{
+	epic_file_flush(log_fd);
+}
+
 /*************************************************************************************************/
 void vBleTask(void *pvParameters)
 {
@@ -248,6 +309,8 @@ void vBleTask(void *pvParameters)
 	 */
 	vTaskDelay(pdMS_TO_TICKS(500));
 
+	log_fd = epic_file_open("ble.log", "w");
+	epic_file_write(log_fd, log_header, sizeof(log_header));
 	/* We are going to execute FreeRTOS functions from callbacks
 	 * coming from this interrupt. Its priority needs to be
 	 * reduced to allow this. */
diff --git a/epicardium/ble/ble_main.c b/epicardium/ble/ble_main.c
index a274f270cbd0d5a74327314eef19c7c7f7dbf75a..7b7c491a41f4c88123e49552270467aed3318fb4 100644
--- a/epicardium/ble/ble_main.c
+++ b/epicardium/ble/ble_main.c
@@ -369,6 +369,7 @@ static void bleSetup(bleMsg_t *pMsg)
  *  \return None.
  */
 /*************************************************************************************************/
+void ble_log_flush(void);
 static void bleProcMsg(bleMsg_t *pMsg)
 {
   uint8_t uiEvent = APP_UI_NONE;
@@ -397,6 +398,8 @@ static void bleProcMsg(bleMsg_t *pMsg)
     case DM_ADV_START_IND:
       LOG_INFO("ble", "Advertisement started");
       uiEvent = APP_UI_ADV_START;
+
+      ble_log_flush();
       break;
 
     case DM_ADV_STOP_IND:
diff --git a/lib/sdk/Libraries/BTLE/wsf/include/wsf_trace.h b/lib/sdk/Libraries/BTLE/wsf/include/wsf_trace.h
index 6bb3d2cd2c5fa11071d7fedb1384884e5b0c378e..00e90ca24a157495bb2f775f0f642dae39e29b2c 100644
--- a/lib/sdk/Libraries/BTLE/wsf/include/wsf_trace.h
+++ b/lib/sdk/Libraries/BTLE/wsf/include/wsf_trace.h
@@ -293,14 +293,10 @@ bool_t WsfTokenService(void);
 /*! \brief 3 argument HCI error trace. */
 #define HCI_TRACE_ERR3(msg, var1, var2, var3)       WSF_TRACE3("HCI", "ERR",  msg, var1, var2, var3)
 
-/*! \brief HCI PDUMP on command. */
-#define HCI_PDUMP_CMD(len, pBuf)
-/*! \brief HCI PDUMP on event. */
-#define HCI_PDUMP_EVT(len, pBuf)
-/*! \brief HCI PDUMP on transmitted ACL message. */
-#define HCI_PDUMP_TX_ACL(len, pBuf)
-/*! \brief HCI PDUMP on Received ACL message. */
-#define HCI_PDUMP_RX_ACL(len, pBuf)
+#define HCI_PDUMP_CMD(len, pBuf)                    WsfPDump(WSF_PDUMP_TYPE_HCI_CMD, len, pBuf)
+#define HCI_PDUMP_EVT(len, pBuf)                    WsfPDump(WSF_PDUMP_TYPE_HCI_EVT, len, pBuf)
+#define HCI_PDUMP_TX_ACL(len, pBuf)                 WsfPDump(WSF_PDUMP_TYPE_HCI_TX_ACL, len, pBuf)
+#define HCI_PDUMP_RX_ACL(len, pBuf)                 WsfPDump(WSF_PDUMP_TYPE_HCI_RX_ACL, len, pBuf)
 
 /*! \brief 0 argument DM info trace. */
 #define DM_TRACE_INFO0(msg)                         WSF_TRACE0("DM", "INFO", msg)
@@ -622,6 +618,25 @@ bool_t WsfTokenService(void);
 #define LL_TRACE_ENABLE(ena)
 #endif
 
+/*! Protocol types */
+typedef enum
+{
+  WSF_PDUMP_TYPE_HCI_CMD    = (1 << 0),
+  WSF_PDUMP_TYPE_HCI_EVT    = (1 << 1),
+  WSF_PDUMP_TYPE_HCI_TX_ACL = (1 << 2),
+  WSF_PDUMP_TYPE_HCI_RX_ACL = (1 << 3),
+  WSF_PDUMP_TYPE_HCI_TX_ISO = (1 << 4),
+  WSF_PDUMP_TYPE_HCI_RX_ISO = (1 << 5),
+  WSF_PDUMP_TYPE_NONE       = 0,
+  WSF_PDUMP_TYPE_ALL        = 0xFFFF
+} wsfPDumpType_t;
+
+/**************************************************************************************************
+  Function Prototypes
+**************************************************************************************************/
+
+void WsfPDump(wsfPDumpType_t pdType, uint16_t length, uint8_t *pBuffer);
+
 /*! \} */    /* WSF_TRACE_API */
 
 #ifdef __cplusplus