#include #include #include #include // Define the UUIDs for service and characteristic #define SERVICE_UUID "6E400001-B5A3-F393-E0A9-E50E24DCCA9E" #define CHARACTERISTIC_UUID_RX "6E400003-B5A3-F393-E0A9-E50E24DCCA9E" #define CHARACTERISTIC_UUID_TX "6E400002-B5A3-F393-E0A9-E50E24DCCA9E" // Declare the characteristic globally BLECharacteristic *pCharacteristic; void setup() { Serial.begin(115200); // Create the BLE Device BLEDevice::init("FizziQ"); // Set your BLE device name // Create the BLE Server BLEServer *pServer = BLEDevice::createServer(); // Create the BLE Service BLEService *pService = pServer->createService(SERVICE_UUID); // Create a BLE Characteristic pCharacteristic = pService->createCharacteristic( CHARACTERISTIC_UUID_TX, BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_NOTIFY ); pCharacteristic->addDescriptor(new BLE2902()); // BLECharacteristic * pRxCharacteristic = pService->createCharacteristic( // CHARACTERISTIC_UUID_TX, // BLECharacteristic::PROPERTY_WRITE // ); // Start the service pService->start(); // Start advertising pServer->getAdvertising()->start(); Serial.println("Waiting for a client connection..."); } void loop() { // Send the temperature value every 5 seconds pCharacteristic->setValue("temperature : 20"); pCharacteristic->notify(); // Send notification if connected delay(2000); pCharacteristic->setValue("temperature : 21"); pCharacteristic->notify(); // Send notification if connected delay(2000); }