How to define the callback for an esp32 arduino ble scan result

axa

The definition to start a BLE scan is:

bool start(uint32_t duration, void (*scanCompleteCB)(BLEScanResults), bool is_continue = false);

The second parameter seems to be the callback when a scan is complete, being somewhat new to this Im unsure how to define it.

fwiw Ive tried this:

void OnScanResults(BLEScanResults scanResults)
{ }

and used it like this:

scanResults = scan->start(60, OnScanResults, true);

but obvious to others, that didnt work.

Please help me decypher that signature

void (*scanCompleteCB)(BLEScanResults)
Tarick Welling

you need to add & to OnScanResults because:

void (*scanCompleteCB)(BLEScanResults)

is a pointer to a function which takes a BLEScanResults, returns nothing and is called scanCompleteCB

So your call should be:

scanResults = scan->start(60, &OnScanResults, true);

just as a pointer to a int points to the address of a int

int pointedTo;
int* ptr = &pointedTo;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can get CRC from android ble scan result?

How do I know if a BLE scan is ongoing?

Android BLE, scan started, finds devices but does not connect with filter (ESP32 & Samsung)

Different WiFi modes in arduino for esp32

arduino-esp32 do OTA via BLE

How to send from ESP32 to Arduino?

How can Firebase acquire data from ESP32/Arduino

Arduino ESP32 how to assign BLEUUID object into string

Interrupts function not called with ESP32 Arduino

Sending Float Data Type from Arduino to ESP32 (NodeMCU)

ESP32 Arduino BLE DeepSleep

ESP32 using BLE and WiFi alternately

How to delete and restart hw timer (for interrupts) on demand for esp32 arduino (stepper motor controller application)

How #define works arduino?

How to increase the scan period for BLE devices in Android?

BLE - Why do I get no callback if the Scan finds nothing?

How to scan BLE devices in Background?

how to identify reason or troubleshoot memory overflow problem on esp32 - arduino

How to fix this Firebase message format sent from ESP32 (Arduino, ESP-IDF - all text, no Firebase library used)

Arduino BLE Project (esp32)

ESP32 IDF Ble Gatt Server Example

How to fix compilation error for ESP32 in Arduino IDE?

Arduino ESP32 FreeRTOS - How to declare empty byte array in task

How to recieve a Direct Method on the ESP32 with azure-sdk-for-c-arduino

Swift BLE communication between iPhone and ESP32

Android ESP32 BLE read after write not working

How to execute debug print from within timer callback in ESP32?

flutter_reactive_ble how to stop scan

BLE sent String between ESP32 and Iphone