ESP32 - how to get Raw BLE-Data?

Hello,

Neil Kolban's ESP32-libraries seem to be very powerful, but i don't understand them. The examples are working without any problems.

Is there any way to get the Raw BLE Data out of of a (passive) BLE-scan with those libraries? Like those Raw-Data that you can get with "nRF-Connect" on Android.

I'd like to receive data from some BLE-Devices that send all their useful data already in the advertisement. There is NO need to establish a connection. They send an advertisement every 2 seconds.

Does anyone have a piece of advice?

Is there any way to get the Raw BLE Data out of of a (passive) BLE-scan with those libraries?

There's no such thing as "raw BLE data". What, specifically, do you want?

Have you got the solution for this ?

Try the BLE Scan Example included inside the Arduino IDE under File menu - Examples - ESP BLE Arduino.

Here is the code:

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

#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>

int scanTime = 5; //In seconds
BLEScan* pBLEScan;

class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
    void onResult(BLEAdvertisedDevice advertisedDevice) {
      Serial.printf("Advertised Device: %s \n", advertisedDevice.toString().c_str());
    }
};

void setup() {
  Serial.begin(115200);
  Serial.println("Scanning...");

  BLEDevice::init("");
  pBLEScan = BLEDevice::getScan(); //create new scan
  pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
  pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
  pBLEScan->setInterval(100);
  pBLEScan->setWindow(99);  // less or equal setInterval value
}

void loop() {
  // put your main code here, to run repeatedly:
  BLEScanResults foundDevices = pBLEScan->start(scanTime, false);
  Serial.print("Devices found: ");
  Serial.println(foundDevices.getCount());
  Serial.println("Scan done!");
  pBLEScan->clearResults();   // delete results fromBLEScan buffer to release memory
  delay(2000);
}

It gives output on serial monitor like this:

Scanning...

Advertised Device: Name: stopmusic, Address: dd:33:0a:11:1a:a5, manufacturer data: 4c000215426c7565436861726d426561636f6e88045701a4c5 

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