esp32-snippets: ESP32 BLE does not connect to Bluetooth LE Lamp (Magic Blue)

Hey guys,

Thanks for the great support with the BLE connection. It works perfectly when I connect to my iBeacon. But I recently encountered the issue, that I am unable to connect to my BLE Light Bulb (Magic Blue).

It looks like the lamp requires a new GATT Client event: Unknown GATT Client event type: 41 Unknown GATT Client event type: 2

Can somebody help me with this issue? I would be really grateful!

ESP32 ESP-WROOM-32

Arduino Code

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

  BLEDevice::init("ESP32");
  Serial.println("Init Bluetooth");

  BLEAddress address("ee:32:4f:a0:b4:06");
  BLEClient*  pClient  = BLEDevice::createClient();
  bool success = pClient->connect(address);
}

Serial Output

Init Bluetooth
[D][BLEDevice.cpp:66] createClient(): >> createClient
[D][BLEDevice.cpp:72] createClient(): << createClient
[D][BLEClient.cpp:103] connect(): >> connect(ee:32:4f:a0:b4:06)
[I][BLEDevice.cpp:600] addPeerDevice(): add conn_id: 0, GATT role: client
[D][FreeRTOS.cpp:165] take(): Semaphore taking: name: RegEvt (0x3ffe7c74), owner: <N/A> for connect
[D][FreeRTOS.cpp:174] take(): Semaphore taken:  name: RegEvt (0x3ffe7c74), owner: connect
[V][FreeRTOS.cpp:70] wait(): >> wait: Semaphore waiting: name: RegEvt (0x3ffe7c74), owner: connect for connect
[V][BLEUtils.cpp:952] gattClientEventTypeToString(): Unknown GATT Client event type: 0
[D][BLEDevice.cpp:154] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][BLEUtils.cpp:952] gattClientEventTypeToString(): Unknown GATT Client event type: 0
[V][BLEUtils.cpp:1284] dumpGattClientEvent(): GATT Event: Unknown
[V][BLEUtils.cpp:952] gattClientEventTypeToString(): Unknown GATT Client event type: 0
[D][BLEClient.cpp:165] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][FreeRTOS.cpp:120] give(): Semaphore giving: name: RegEvt (0x3ffe7c74), owner: connect
[V][FreeRTOS.cpp:86] wait(): << wait: Semaphore released: name: RegEvt (0x3ffe7c74), owner: connect
[D][FreeRTOS.cpp:165] take(): Semaphore taking: name: OpenEvt (0x3ffe7eb8), owner: <N/A> for connect
[D][FreeRTOS.cpp:174] take(): Semaphore taken:  name: OpenEvt (0x3ffe7eb8), owner: connect
[V][FreeRTOS.cpp:70] wait(): >> wait: Semaphore waiting: name: OpenEvt (0x3ffe7eb8), owner: connect for connect
[V][BLEUtils.cpp:952] gattClientEventTypeToString(): Unknown GATT Client event type: 41
[D][BLEDevice.cpp:154] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][BLEUtils.cpp:952] gattClientEventTypeToString(): Unknown GATT Client event type: 41
[V][BLEUtils.cpp:1284] dumpGattClientEvent(): GATT Event: Unknown
[V][BLEUtils.cpp:952] gattClientEventTypeToString(): Unknown GATT Client event type: 41
[D][BLEClient.cpp:165] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[I][BLEDevice.cpp:611] removePeerDevice(): remove: 0, GATT role client
[V][FreeRTOS.cpp:120] give(): Semaphore giving: name: RssiCmplEvt (0x3ffe7f78), owner: <N/A>
[V][FreeRTOS.cpp:120] give(): Semaphore giving: name: SearchCmplEvt (0x3ffe7f18), owner: <N/A>
[V][BLEUtils.cpp:952] gattClientEventTypeToString(): Unknown GATT Client event type: 2
[D][BLEDevice.cpp:154] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][BLEUtils.cpp:952] gattClientEventTypeToString(): Unknown GATT Client event type: 2
[V][BLEUtils.cpp:1284] dumpGattClientEvent(): GATT Event: Unknown
[V][BLEUtils.cpp:952] gattClientEventTypeToString(): Unknown GATT Client event type: 1
[D][BLEDevice.cpp:154] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][BLEUtils.cpp:952] gattClientEventTypeToString(): Unknown GATT Client event type: 1
[V][BLEUtils.cpp:1284] dumpGattClientEvent(): GATT Event: Unknown

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19

Most upvoted comments

After investigating more time, I’ve found the problem.

The signature of BLEClient->connect is the following: bool connect(BLEAddress address, esp_ble_addr_type_t type = BLE_ADDR_TYPE_PUBLIC);

So by default it uses the BLE_ADDR_TYPE_PUBLIC, but my BLE light bulb needed the type BLE_ADDR_TYPE_RANDOM.

Working code

BLEClient*  pClient  = BLEDevice::createClient();
bool success = pClient->connect(address,BLE_ADDR_TYPE_RANDOM);

Can you quickly explain, what the difference is?