 uint8_t outBufMidi[128];
 int outBufMidiPtr;
 
-// TXRX Service
+// MIDI BLE Service UUIDs
 static const uint8_t uart_base_uuid[] = {0x03, 0xB8, 0x0E, 0x5A, 0xED, 0xE8, 0x4B, 0x33, 0xA7, 0x51, 0x6C, 0xE3, 0x4E, 0xC4, 0xC7, 0};
 static const uint8_t uart_tx_uuid[]   = {0x77, 0x72, 0xE5, 0xDB, 0x38, 0x68, 0x41, 0x12, 0xA1, 0xA9, 0xF2, 0x66, 0x9D, 0x10, 0x6B, 0xF3};
 static const uint8_t uart_rx_uuid[]   = {0x77, 0x72, 0xE5, 0xDB, 0x38, 0x68, 0x41, 0x12, 0xA1, 0xA9, 0xF2, 0x66, 0x9D, 0x10, 0x6B, 0xF3};

  pinMode(10, OUTPUT);
  digitalWrite(10, HIGH);

  //DEBUG_PRINTLN("BLE Arduino Slave");
  Usb.Init();
  delay(500);
  Serial.begin(9600);

    pid = Midi.pid;
  }

  do
  {
    if ( (size = Midi.RecvData(outBuf)) > 0 ) {
      // Send data to parser
      parseMIDItoAppleBle(size, outBuf);
    }
  } while (size > 0);

 uint32_t err_code = NRF_SUCCESS;
}


/*******************************************************************************
 * Convert MIDI Data to MIDI-BLE Packets
 *******************************************************************************/
void parseMIDItoAppleBle(int size, byte outBuf[3])
{
  char time[2];
  char buf[20];
  unsigned long timer = 0;
  int lastPos;
  timer = millis();
  uint16_t blueMidiTime = 0;
  blueMidiTime = 32768 + (timer % 16383);

  uint32_t err_code = NRF_SUCCESS;
  int localBufNum = rx_buf_num;

  if(rx_buf_num <= 100) // arbitrary high number
  {
    if (rx_buf_num % 17 == 0) // End of packet, start a new one
    {
      rx_buf[rx_buf_num] = blueMidiTime >> 8;
      rx_buf_num++;
      rx_buf[rx_buf_num] = 0x80;
      rx_buf_num++;
    }
    else
    {
      rx_buf[rx_buf_num] = 0x80;
      rx_buf_num++;
    }
    for (int i = 0; i < size; i++)
    {
      rx_buf[rx_buf_num] = outBuf[i];
      rx_buf_num++;
    }
  }
}


/*******************************************************************************
 * Convert MIDI BLE to MIDI USB
