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 UUID for the beacon #define BEACON_UUID "12345678-1234-5678-1234-56789abcdef0" void setup() { Serial.begin(115200); BLEDevice::init(""); // Initialize BLE with an empty name // Create the BLE Server BLEServer *pServer = BLEDevice::createServer(); // Create the BLE Service (we use a custom UUID here) BLEService *pService = pServer->createService(BEACON_UUID); // Create a BLE Characteristic BLECharacteristic *pCharacteristic = pService->createCharacteristic( BLEUUID("12345678-1234-5678-1234-56789abcdef1"), BLECharacteristic::PROPERTY_READ ); // Set the value of the characteristic (this will be broadcasted) pCharacteristic->setValue("ESP32 Beacon"); // Start the service pService->start(); // Create the BLE Advertising object BLEAdvertising *pAdvertising = BLEDevice::getAdvertising(); pAdvertising->addServiceUUID(BEACON_UUID); pAdvertising->setScanResponse(true); // Set advertising parameters pAdvertising->setMinPreferred(0x06); // Function to change advertising interval pAdvertising->setMaxPreferred(0x12); // Function to change advertising interval // Start advertising pAdvertising->start(); Serial.println("BLE Beacon is now advertising..."); } 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)