I would like to deep my knowledge in BLE Profile implementation.
I have seen commercial products (i.e. HUE BLE) the following profile using i.e. LightBlue tool
Device name
UUIDD: xxxxxxx-xxxxxx-xxxx-xxxx
Connected
ADVERTISEMENT DATA show
Device information
MANUFACTURER NAME STRING
xxxxxxxxxxxxx
Model Number String
xxxxxx
Software Revision String
xxxxx
I have not found any information about how to generate the “Device information” on a BLE server.
Thanks in advance for any advice or link to this topic
Hi.
To be honest, I’m not sure how to do that. I couldn’t find any information regarding that.
But, I think you need to create a Device Information service that contains the characteristics you want to add to define the device (like the ones you’ve shown: manufacturer, model number, software revision, etc).
Regards,
Sara
Hi Sara
Thanks for your hint. It doesnot belong to the the Profile as I thought
You have to define a Service / Characteristics with predefined UUID
Service UUID 180A
Characteristic 1 UUID: 2A24 For Model Number String
Characteristic 2 UUID: 2A28 For Software Revision String
Characteristic 3 UUID: 2A29 For Manufacter Name String
Now is working !!!!
THANKS
Status: SOLVED
Great! That’s what I thought.
I’ll mark this issue as resolved.
If you need further help, you just need to open a new question in our forum.
Regards,
Sara
I would love to know more about this myself. Do you have code you could post? Or maybe a web site I could reference?
/*
Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleNotify.cpp
Ported to Arduino ESP32 by Evandro Copercini
updated by chegewara
*/
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>
#define LED_PIN 13 // Pin for LED to indicate estado
uint8_t newMACAddress[] = {0x90, 0x84, 0x2B, 0x4A, 0x3A, 0x0A}; // BLE address
//======================================================================================
// DEVICE INFORMATION
#define SERVICE_UUID_1 “180A”
#define CHARACTERISTIC_UUID_1_1 “2A29” // Manufacter
#define CHARACTERISTIC_UUID_1_2 “2A24” // Model
#define CHARACTERISTIC_UUID_1_3 “2A28” // SW
#define SERVICE_UUID_2 “932c32bd-0000-47a2-835a-a8d455b859dd”
#define CHARACTERISTIC_UUID_2_1 “932c32bd-0001-47a2-835a-a8d455b859dd”
#define CHARACTERISTIC_UUID_2_2 “932c32bd-0002-47a2-835a-a8d455b859dd”
//======================================================================================
BLEServer* pServer = NULL;
BLECharacteristic* pCharacteristic_1_1 = NULL;
BLECharacteristic* pCharacteristic_1_2 = NULL;
BLECharacteristic* pCharacteristic_1_3 = NULL;
BLECharacteristic* pCharacteristic_2_1 = NULL;
BLECharacteristic* pCharacteristic_2_2 = NULL;
bool deviceConnected = false;
bool oldDeviceConnected = false;
uint32_t value = 0;
// See the following for generating UUIDs:
// https://www.uuidgenerator.net/
class MyServerCallbacks: public BLEServerCallbacks {
void onConnect(BLEServer* pServer) {
deviceConnected = true;
BLEDevice::startAdvertising();
};
void onDisconnect(BLEServer* pServer) {
deviceConnected = false;
}
};
void setup() {
pinMode(LED_PIN, OUTPUT); //GPIO output for LED
byte value_init;
delay(4000);
Serial.begin(115200);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Create the BLE Device
esp_base_mac_addr_set(&newMACAddress[0]);
BLEDevice::init(“Internal LED Control”);
// Create the BLE Server
pServer = BLEDevice::createServer();
pServer->setCallbacks(new MyServerCallbacks());
// Create BLE Services
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// DEVICE INFORMATION
BLEService *pService_1 = pServer->createService(SERVICE_UUID_1);
// Create a BLE Characteristic (Manufacturer Name String)
pCharacteristic_1_1 = pService_1->createCharacteristic(
CHARACTERISTIC_UUID_1_1,
BLECharacteristic::PROPERTY_READ
);
pCharacteristic_1_1->setValue(“My factory”);
// Create a BLE Characteristic
pCharacteristic_1_2 = pService_1->createCharacteristic(
CHARACTERISTIC_UUID_1_2,
BLECharacteristic::PROPERTY_READ
);
pCharacteristic_1_2->setValue(“Ref: 1”);
// Create a BLE Characteristic
pCharacteristic_1_3 = pService_1->createCharacteristic(
CHARACTERISTIC_UUID_1_3,
BLECharacteristic::PROPERTY_READ
);
pCharacteristic_1_3->setValue(“1.0”);
// Start the service
pService_1->start();
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BLEService *pService_2 = pServer->createService(SERVICE_UUID_2);
// Create a BLE Characteristic
pCharacteristic_2_1 = pService_2->createCharacteristic(
CHARACTERISTIC_UUID_2_1,
BLECharacteristic::PROPERTY_READ
);
pCharacteristic_2_1->setValue(“LED”);
// Create a BLE Characteristic 2 del servivio 2
pCharacteristic_2_2 = pService_2->createCharacteristic(
CHARACTERISTIC_UUID_2_2,
BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_WRITE |
BLECharacteristic::PROPERTY_NOTIFY
);
// Init LED status 0x00 OFF 0x01 ON
value_init = 0x00;
pCharacteristic_2_2->setValue((uint8_t*)&value_init, 1);
// Start the service
pService_2->start();
// Start advertising
BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
pAdvertising->start();
pAdvertising->setScanResponse(false);
pAdvertising->setMinPreferred(0x0); // set value to 0x00 to not advertise this parameter
BLEDevice::startAdvertising();
Serial.println(“Waiting a client connection to notify…”);
}
void loop() {
// notify changed value
if (deviceConnected) {
//////////////////////////////////////////////////////////////
// Check Characteristic 2 from Service 2
if( (pCharacteristic_2_2->getValue()[0]) == 1)
{ digitalWrite(LED_PIN, HIGH);
}
else{
digitalWrite(LED_PIN, LOW);
}
//////////////////////////////////////////////////////////////
delay(100);
}
// disconnecting
if (!deviceConnected && oldDeviceConnected) {
delay(500); // give the bluetooth stack the chance to get things ready
pServer->startAdvertising(); // restart advertising
Serial.println(“start advertising”);
oldDeviceConnected = deviceConnected;
}
// connecting
if (deviceConnected && !oldDeviceConnected) {
// do stuff here on connecting
oldDeviceConnected = deviceConnected;
}
}
I hope it will be helpfull
You can control with the APP LightBlue the value of the characteristic 2 (in service 2) and change the ESP32 led status
write 00 -> ESP32 Internal led (GPIO 13) will be off
or
write 01 -> ESP32 Internal led (GPIO 13) will be on