Files
J1B4-Fitbot/code/arduino/bluetoothEsp/bluetoothEsp.ino
2024-05-20 14:27:30 +02:00

33 lines
862 B
C++

#include <BLEDevice.h>
#include <BLEServer.h>
// Define the service UUID
#define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
// Define the characteristic UUID
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"
void setup() {
// Create a BLE server
BLEServer *pServer = BLEDevice::createServer();
// Create a BLE service
BLEService *pService = pServer->createService(SERVICE_UUID);
// Create a BLE characteristic
BLECharacteristic *pCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID, BLECharacteristic::PROPERTY_READ);
// Set the characteristic value
pCharacteristic->setValue("Hello, Bluetooth!");
// Start the service
pService->start();
// Start advertising the service
pServer->getAdvertising()->start();
}
void loop() {
// Nothing to do here
}