BLE device connection with ESP 32 using the specified MAC address

I am using the ESP32 dev module and would like to connect the BLE device using the specified MAC address. Kindly help me how to do it?

Welcome to the forum

Your topic was MOVED to its current forum category which is more appropriate than the original as it has nothing to do with Installation and Troubleshooting of the IDE

Kindly show what You've achieved so far.

Since I am new to this. I am trying to get connected with the BLEscan example, but i would like to know how to get connected with the specified mac address. Kindly help me out.
/original*
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>
***********************/
#include <Arduino.h>
#include <NimBLEDevice.h>

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

class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
/*** Only a reference to the advertised device is passed now
void onResult(BLEAdvertisedDevice advertisedDevice) { /
void onResult(BLEAdvertisedDevice
advertisedDevice) {
/
* Serial.printf("Advertised Device: %s \n", advertisedDevice.toString().c_str()); **/
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(20000);
}

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

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