 
 /*******************************************************************************
 * Callback for INCOMING MIDI BLE Data
-*
-*
 *******************************************************************************/
-
 void onDataWritten(uint16_t charHandle)
 {
   uint8_t buf[TXRX_BUF_LEN];
   uint16_t bytesRead;
-	Serial.println("Something");
+  char debugBuf[23];
   if ( charHandle == txCharacteristic.getHandle() )
   {
     ble.readCharacteristicValue(txCharacteristic.getHandle(), buf, &bytesRead);
     parseBLEtoMIDI(buf, bytesRead);
+    sprintf(debugBuf, " READ: %i", bytesRead);
+    Serial.print(debugBuf);
+    Serial.println();
   }
 }
 
 void setup(void)
 {
+  prsState = STRT; // Assuming MIDI
   bFirst = true;
   vid = pid = 0;
   isConnected = false;
   uint32_t err_code = NRF_SUCCESS;
   uart_callback_t uart_cb;
   Serial.begin(9600);
-	
+
   //Workaround for non UHS2.0 Shield
   pinMode(10, OUTPUT);
   digitalWrite(10, HIGH);

uint8_t txPayload[TXRX_BUF_LEN] = {0,};
uint8_t rxPayload[TXRX_BUF_LEN] = {0,};

GattCharacteristic  txCharacteristic (uart_tx_uuid, txPayload, 1, 20,
                                     GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ);

GattCharacteristic *uartChars[] = {&txCharacteristic};
GattService         uartService(uart_base_uuid, uartChars, sizeof(uartChars) / sizeof(GattCharacteristic *));



/*******************************************************************************
 * INITIALIZE USB MIDI Variables

  ble.startAdvertising();
}

void connectionCallback(void)
{
  isConnected = true;
  uint32_t err_code = NRF_SUCCESS;
  err_code = app_timer_create(&m_uart_rx_id, APP_TIMER_MODE_REPEATED, m_uart_rx_handle);
  APP_ERROR_CHECK(err_code);
  err_code = app_timer_start(m_uart_rx_id, STATUS_CHECK_TIME, NULL);
  APP_ERROR_CHECK(err_code);
}
