Differences

This shows you the differences between two versions of the page.

Link to this comparison view

iothings:laboratoare:2025:lab1 [2025/09/25 22:37]
dan.tudose
iothings:laboratoare:2025:lab1 [2025/10/24 21:12] (current)
dan.tudose [Lab 1. WiFi Server]
Line 1: Line 1:
-===== Lab 1Getting Started ======+===== Lab 1Getting Started. WiFi Basics ​======
  
 ===== Necessary gear ===== ===== Necessary gear =====
Line 727: Line 727:
 </​note>​ </​note>​
  
-=== 6. Advertise on BLE  === 
  
-Build the example below, which advertises the board on BLE. Install on your phone an app that scans nearby Bluetooth devices, such as [[https://​play.google.com/​store/​apps/​details?​id=no.nordicsemi.android.mcp&​hl=en&​pli=1| nRF Connect]]. Check if your device is in the list. 
- 
-<code C main.cpp>​ 
-#include <​Arduino.h>​ 
-#include <​NimBLEDevice.h>​ 
- 
-static const char* DEVICE_NAME = "​ESP32-C6 Demo"; 
-static NimBLEUUID SERVICE_UUID("​6E400001-B5A3-F393-E0A9-E50E24DCCA9E"​);​ 
-static NimBLEUUID CHAR_UUID ​  ​("​6E400002-B5A3-F393-E0A9-E50E24DCCA9E"​);​ 
- 
-NimBLEServer* ​        ​gServer = nullptr; 
-NimBLEService* ​       gService = nullptr; 
-NimBLECharacteristic* gChar = nullptr; 
- 
-void startBLE() { 
-  NimBLEDevice::​init(DEVICE_NAME);​ 
- 
-  gServer ​ = NimBLEDevice::​createServer();​ 
-  gService = gServer->​createService(SERVICE_UUID);​ 
- 
-  gChar = gService->​createCharacteristic( 
-    CHAR_UUID, 
-    NIMBLE_PROPERTY::​READ 
-  ); 
-  gChar->​setValue("​Hello from ESP32-C6!"​);​ 
-  gService->​start();​ 
- 
-  NimBLEAdvertising* adv = NimBLEDevice::​getAdvertising();​ 
- 
-  // Advertise our service UUID 
-  adv->​addServiceUUID(SERVICE_UUID);​ 
- 
-  // (v2.x) Build advertising + scan-response payloads explicitly 
-  NimBLEAdvertisementData advData; 
-  advData.setFlags(0x06);​ // LE General Discoverable + BR/EDR Not Supported 
- 
-  NimBLEAdvertisementData scanData; 
-  scanData.setName(DEVICE_NAME);​ // put the name in scan response 
-  // you can also add manufacturer data here if you want: 
-  // std::string mfg = "​\x34\x12C6";​ scanData.setManufacturerData(mfg);​ 
- 
-  adv->​setAdvertisementData(advData);​ 
-  adv->​setScanResponseData(scanData);​ 
- 
-  // Appearance is still supported 
-  adv->​setAppearance(0x0200);​ // Generic Tag 
- 
-  NimBLEDevice::​startAdvertising();​ 
-} 
- 
-void setup() { 
-  Serial.begin(115200);​ 
-  while (!Serial) { delay(10); } 
-  startBLE(); 
-  Serial.println("​Advertising as ESP32-C6 Demo. Open nRF Connect -> Scan."​);​ 
-} 
- 
-void loop() { 
-  delay(1000);​ 
-} 
- 
-</​code>​ 
- 
-{{:​iothings:​laboratoare:​lab1-ble-scanner.jpg?​300|}} 
 ===== Resources ===== ===== Resources =====
  
iothings/laboratoare/2025/lab1.1758829023.txt.gz · Last modified: 2025/09/25 22:37 by dan.tudose
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0