#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>
// Define the service and characteristic UUIDs
#define SERVICE_UUID "d41f5c92-a147-4be1-9af2-21ddeee63087"
#define CHARACTERISTIC_UUID "57f50f8a-80d4-4694-a151-c1a081f4f99a"
BLEServer* pServer = NULL;
BLECharacteristic* pCharacteristic = NULL;
void setup() {
// Create the BLE Device
BLEDevice::init("ESP32 BLE Server");
// Create the BLE Server
pServer = BLEDevice::createServer();
// Create the BLE Service
BLEService *pService = pServer->createService(SERVICE_UUID);
// Create the BLE Characteristic
pCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ
);
// Add a descriptor
pCharacteristic->addDescriptor(new BLE2902());
// Start the service
pService->start();
// Start advertising
pServer->getAdvertising()->start();
}
void loop() {
// Nothing to do here
}