   
   //look for in-coming serial messages (via USB or via Bluetooth)
   if (Serial.available()) respondToByte((char)Serial.read());   //USB Serial
-  if (Serial1.available()) respondToByte((char)Serial1.read()); //BT Serial
+
+  //respond to BLE
+  if (ble.available() > 0) {
+    String msgFromBle; int msgLen = ble.recvBLE(&msgFromBle);
+    for (int i=0; i < msgLen; i++) respondToByte(msgFromBle[i]);
+  }
+
+  //service the BLE advertising state
+  ble.updateAdvertising(millis(),5000); //check every 5000 msec to ensure it is advertising (if not connected)
 
 } //end loop();
 

#include "TympanRemoteFormatter.h"
TympanRemoteFormatter myGUI;  //Creates the GUI-writing class for interacting with TympanRemote App


// define the setup() function, the function that is called once when the device is booting
const float input_gain_dB = 10.0f; //gain on the microphone

}

void setButtonText(String btnId, String text) {
  String str = "TEXT=BTN:" + btnId + ":"+text;
  myTympan.println(str);
  ble.sendMessage(str);
}
