Using a custom Advertising Address

Posts: 9
Joined: Sat Jan 20, 2018 9:34 am

Using a custom Advertising Address

Postby ruppie » Wed Jul 15, 2020 5:16 am

i am building a "digital twin" of an LEGO technic Hub, by using an ESP32.
Target is that ESP32 can be connected to LEGO BLE Apps.

At least i have concerns, that one reason i did not get a connecteion request is because LEGO Apps using Address Filters .
An Example of a LEGO HUB Adress is like:Advertising Address: LegoSyst_4a:3a:0c (90:84:2b:4a:3a:0c) ( a hub owned by me)
As you may know ours is like: Advertising Address: Espressi_cb:69:fa (bc:dd:c2:cb:69:fa)

Question is, how to change Advertising address is scetch to be shown as "LegoSyste" like : 90:84:2b:aa:bb:cc for example

Thanks in advance


Posts: 1211
Joined: Wed Jun 14, 2017 9:00 pm

Re: Using a custom Advertising Address

Postby chegewara » Wed Jul 15, 2020 3:32 pm

Start with this:

As you can see this is part of mac addresses registered by LEGO System A/S, and here is espressif:

I dont remember now if you can set particular bluetooth mac with IDF API, but its not possible with arduino library.

Posts: 9
Joined: Sat Jan 20, 2018 9:34 am

Re: Using a custom Advertising Address

Postby ruppie » Wed Jul 15, 2020 7:54 pm

"but its not possible with arduino library."

It was solved by another helping hand:

Code: Select all

    Based on Neil Kolban example for IDF:
    Ported to Arduino ESP32 by Evandro Copercini
    updates by chegewara

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

// Set your new MAC Address
uint8_t newMACAddress[] = {0x90, 0x84, 0x2B, 0x4A, 0x3A, 0x0A};

// See the following for generating UUIDs:

#define SERVICE_UUID        "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"

void setup() {
  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(
                                         BLECharacteristic::PROPERTY_READ |

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

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

Who is online

Users browsing this forum: No registered users and 15 guests