Trying to retrieve UUID from a BLE device

I'm not lazy, just the opposite. I try to do my own research, but there are very few examples on this forum and on the internet referencing the retrieval of the UUID from a BLE device. I want the 32 byte UUID, not the 4 byte one.

Here is my sketch:

#include <BLEAdvertisedDevice.h>
#include <BLEDevice.h>
#include <BLEScan.h>
#include "BLEUtils.h"
#include "sdkconfig.h"
#include <sstream>
#include "BLEAdvertisedDevice.h"
#include "BLEUtils.h"
#include "esp32-hal-log.h"

const int PIN = 4;
const int CUTOFF = -60;

void setup() {
  pinMode(PIN, OUTPUT);
  BLEDevice::init("");
  int first = 100;
  int second = 200;
  Serial.begin(9600);
  Serial.println(first);
  Serial.println(second);
}

void loop() {
  BLEScan *scan = BLEDevice::getScan();
  scan->setActiveScan(true);
  BLEScanResults results = scan->start(1);
  int best = CUTOFF;
  for (int i = 0; i < results.getCount(); i++) {
    BLEAdvertisedDevice device = results.getDevice(i);
    int rssi = device.getRSSI();
    if (rssi > best) {
      best = rssi;
    }
  }
  digitalWrite(PIN, best > CUTOFF ? HIGH : LOW);
  if (PIN, best > CUTOFF) {
 BLEUUID BLEAdvertisedDevice::getServiceUUID() ;
  digitalWrite(PIN, LOW);
  delay(10000);
  }
}

When compiling, the sketch stops at: BLEUUID BLEAdvertisedDevice::getServiceUUID(); with this error message:
exit status 1
qualified-id in declaration before '(' token

First, BLE extended UUID contains 16 bytes (128 bits) , not 32 bytes

About your code - please edit your message and insert code in code tags.

Then go to File->Preferences in Arduino IDE and set ON to the option "Output detailed information during compilation" (or something like).
Compile your code again and show detailed error diagnostics.

Thank You b707 for your response. I'm a noob and still trying to learn and I appreciate your patience with me. I did what you said and put my code in code tags. However, when I turned on "verbose" in the preferences tab and compiled my program and copied all of the compiling info, the forum system told me that I went substantially over the limit of characters that are allow to be on a post. You are right, the UUID is 16 bytes. The last 16 bytes is the alias and name.

I found my solution and even the complete code to accomplish my goal and finish my project. Wonderful video produced by TECHIESMS STUDIO. Unlock Door using BLE keychain,Earpods,Smart Watch etc.. | BLE Beacon | Smart Lock - YouTube The developer provides a link to his code on his website: https://techiesms.com/unlock-your-door-using-airpods-smart-watch-or-smart-keychain/ and also via a link on the YouTube video.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.