 #include <BLEUtils.h>
 #include <BLE2902.h>
 
+BLEServer *pServer = NULL;
 BLECharacteristic *pCharacteristic;
 bool deviceConnected = false;
+bool oldDeviceConnected = false;
 uint8_t value = 0;
 
 // See the following for generating UUIDs:

}

void loop() {

  if (deviceConnected) {
    Serial.printf("*** NOTIFY: %d ***\n", value);
    pCharacteristic->setValue(&value, 1);
    pCharacteristic->notify();
    //pCharacteristic->indicate();
    value++;
  }
  delay(2000);
}
  BLEDevice::init("MyESP32");

  // Create the BLE Server
  pServer = BLEDevice::createServer();
  pServer->setCallbacks(new MyServerCallbacks());

  // Create the BLE Service
