Skip to content

Services are duplicating when 16-bit UUID Number is used for a service #6750

Closed
@aarbmx6s

Description

@aarbmx6s

Board

DOIT ESP32 DEVKIT V1

Device Description

DOIT ESP32 DEVKIT V1

Hardware Configuration

Nothing attached

Version

v2.0.2

IDE Name

Arduino IDE

Operating System

macOS 12.3.1

Flash frequency

80 MHz

PSRAM enabled

no

Upload speed

921600

Description

Hi there!

I am faced with the situation when service UUID is a 16-bit UUID Number taken from the official specifications document, for example, 0x180D ("180D"), and the LightBlue app shows that peripheral has 2 services:

image

Inside the peripheral device in the advertisement section UUIDs of service are displayed twice:

image

I used the next example where I replaced UUIDs on my own.

When service UUID is random (like in the example) everything is OK.

Sketch

/*
    Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleServer.cpp
    Ported to Arduino ESP32 by Evandro Copercini
    updates by chegewara
*/

#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>

// See the following for generating UUIDs:
// https://www.uuidgenerator.net/

#define SERVICE_UUID        "180D"
#define CHARACTERISTIC_UUID "2A19"

void setup() {
  Serial.begin(115200);
  Serial.println("Starting BLE work!");

  BLEDevice::init("Long name works now");
  BLEServer *pServer = BLEDevice::createServer();
  BLEService *pService = pServer->createService(SERVICE_UUID);
  BLECharacteristic *pCharacteristic = pService->createCharacteristic(
                                         CHARACTERISTIC_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );

  pCharacteristic->setValue("Hello World says Neil");
  pService->start();
  // BLEAdvertising *pAdvertising = pServer->getAdvertising();  // this still is working for backward compatibility
  BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
  pAdvertising->addServiceUUID(SERVICE_UUID);
  pAdvertising->setScanResponse(true);
  pAdvertising->setMinPreferred(0x06);  // functions that help with iPhone connections issue
  pAdvertising->setMinPreferred(0x12);
  BLEDevice::startAdvertising();
  Serial.println("Characteristic defined! Now you can read it in your phone!");
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(2000);
}

Debug Message

-

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions