From 27a5e27972b3a179d067b65ca88bebc8da661778 Mon Sep 17 00:00:00 2001 From: pulipakaa24 Date: Sat, 10 Jan 2026 23:44:55 -0600 Subject: [PATCH] mac address update for taskDriven --- include/BLE.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/BLE.cpp b/include/BLE.cpp index 30a3da0..7680222 100644 --- a/include/BLE.cpp +++ b/include/BLE.cpp @@ -8,6 +8,8 @@ #include "bmHTTP.hpp" #include #include "setup.hpp" +#include "esp_mac.h" + std::atomic flag_scan_requested{false}; std::atomic isBLEClientConnected{false}; @@ -28,6 +30,7 @@ std::atomic authConfirmChar = nullptr; std::atomic credsChar = nullptr; std::atomic tokenChar = nullptr; std::atomic ssidRefreshChar = nullptr; +std::atomic deviceInfoChar = nullptr; static QueueHandle_t BLE_event_queue = NULL; static TaskHandle_t BLE_manager_task_handle = NULL; @@ -100,6 +103,27 @@ NimBLEAdvertising* initBLE() { ); connectConfirmChar.load()->createDescriptor("2902"); // Add BLE2902 descriptor for notifications + // 0x0006 - Device Info (READ) - MAC address and other device details + deviceInfoChar = pService->createCharacteristic( + "0006", + NIMBLE_PROPERTY::READ + ); + // Build device info JSON with MAC address + uint8_t mac[6]; + esp_read_mac(mac, ESP_MAC_WIFI_STA); + char macStr[18]; + snprintf(macStr, sizeof(macStr), "%02X:%02X:%02X:%02X:%02X:%02X", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + + cJSON *infoRoot = cJSON_CreateObject(); + cJSON_AddStringToObject(infoRoot, "mac", macStr); + cJSON_AddStringToObject(infoRoot, "firmware", "1.0.0"); + cJSON_AddStringToObject(infoRoot, "model", "BlindMaster-C6"); + char *infoJson = cJSON_PrintUnformatted(infoRoot); + deviceInfoChar.load()->setValue(std::string(infoJson)); + cJSON_Delete(infoRoot); + free(infoJson); + // Start pService->start();