#include <ArduinoBLE.h>
BLEService ledService("77B10000-E8F2-537F-4F6C-D104768A1777"); // BLE LED Service
// BLE LED Switch Characteristic - custom 128-bit UUID, read and writable by central
BLEByteCharacteristic switchCharacteristic("77B10001-E8F2-537F-4F6C-D104768A1777", BLERead | BLEWrite);
const int ledPin = LED_BUILTIN; // pin to use for the LED
void setupToConfigLedAndBle() {
Serial.begin(9600);
while (!Serial);
// set LED pin to output mode
pinMode(ledPin, OUTPUT);
// begin initialization
if (!BLE.begin()) {
Serial.println("starting BLE failed!");
while (1);
}
BLE.setLocalName("xxxxxx");
BLE.setDeviceName("xxxxxx");
String address = BLE.address();
BLE.setAdvertisedService(ledService);
// add the characteristic to the service
ledService.addCharacteristic(switchCharacteristic);
// add service
BLE.addService(ledService);
// set the initial value for the characeristic:
switchCharacteristic.writeValue(0);
// start advertising
BLE.advertise();
Serial.println("xxxxxx visible...");
}