Skip to content

BluetoothSerial: register_callback compile error - but I think it is probably a problem with the compiler not the BluetoothSerial library #7675

Closed
@paulhamsh

Description

@paulhamsh

Board

ESP32 Dev Module

Device Description

Not relevant because not uploading - compile issue

Hardware Configuration

N/A

Version

v2.0.6

IDE Name

Arduino 2.0.3

Operating System

Windows 11

Flash frequency

80MHz

PSRAM enabled

no

Upload speed

921600

Description

I get this error in v2.0.6 - but not in v2..0.5 or any version below that.
What is really weird is that I can't see any difference in the src files for register_callback.

I have updated to v2.0.6 and copied in the BluetoothSerial folder from v2.0.5 into C:\Users\Paul\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.6\libraries to see if that helped, restarted the IDE and it made no difference.

**So - whilst it states it is an error in matching a function call, it isn't caused by the library in BluetoothSerial.....so is there some compiler change with v2.0.6 that changes how functions are located and matched?

Or a default compiler setting has changed?**

C:\Users\Paul\Desktop\sketch_jan7a\sketch_jan7a.ino: In function 'void setup()':
C:\Users\Paul\Desktop\sketch_jan7a\sketch_jan7a.ino:24:38: error: no matching function for call to 'BluetoothSerial::register_callback(void (&)(esp_spp_cb_event_t, esp_spp_cb_param_t*))'
   SerialBT.register_callback(callback);
                                      ^
In file included from C:\Users\Paul\Desktop\sketch_jan7a\sketch_jan7a.ino:7:
C:\Users\Paul\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.6\libraries\BluetoothSerial\src/BluetoothSerial.h:56:19: note: candidate: 'esp_err_t BluetoothSerial::register_callback(void (**)(esp_spp_cb_event_t, esp_spp_cb_param_t*))'
         esp_err_t register_callback(esp_spp_cb_t * callback);
                   ^~~~~~~~~~~~~~~~~
C:\Users\Paul\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.6\libraries\BluetoothSerial\src/BluetoothSerial.h:56:19: note:   no known conversion for argument 1 from 'void(esp_spp_cb_event_t, esp_spp_cb_param_t*)' to 'void (**)(esp_spp_cb_event_t, esp_spp_cb_param_t*)'

exit status 1

Compilation error: no matching function for call to 'BluetoothSerial::register_callback(void (&)(esp_spp_cb_event_t, esp_spp_cb_param_t*))'

Sketch

// Works in 2.0.2
// Works in 2.0.3
// Works in 2.0.4
// Works in 2.0.5
// Doesn't work in 2.0.6

#include "BluetoothSerial.h"
 
BluetoothSerial SerialBT;
 
void callback(esp_spp_cb_event_t event, esp_spp_cb_param_t *param){
  if(event == ESP_SPP_SRV_OPEN_EVT){
    Serial.println("Client Connected");
  }
 
  if(event == ESP_SPP_CLOSE_EVT ){
    Serial.println("Client disconnected");
  }
}
 
void setup() {
  Serial.begin(115200);
 
  SerialBT.register_callback(callback);
 
  if(!SerialBT.begin("ESP32")){
    Serial.println("An error occurred initializing Bluetooth");
  }else{
    Serial.println("Bluetooth initialized");
  }
}
 
void loop() {}


### Debug Message

```plain
N/A - compile error

Other Steps to Reproduce

Just load sketch and try to complile it

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions