Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
#include
#include
// Define the BLE Service and Characteristic UUIDs #define SERVICE_UUID "12345678-1234-5678-1234-56789abcdef0" #define CHARACTERISTIC_UUID "12345678-1234-5678-1234-56789abcdef1" // Create a BLE Server and Characteristic BLEServer *pServer = nullptr; BLECharacteristic *pCharacteristic = nullptr; void setup() { Serial.begin(115200); BLEDevice::init("ESP32_BLE_Server"); // Initialize BLE with a name // 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 ); // Set the initial value of the characteristic pCharacteristic->setValue("Hello from ESP32"); // Start the service pService->start(); // Start advertising BLEAdvertising *pAdvertising = BLEDevice::getAdvertising(); pAdvertising->addServiceUUID(SERVICE_UUID); pAdvertising->start(); Serial.println("BLE Server is running, waiting for clients to connect..."); } void loop() { // Nothing to do here }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)