Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
paulhamsh opened this issue Jan 8, 2023 · 3 comments · Fixed by #7681
Labels
Status: Awaiting triage Issue is waiting for triage

Comments

@paulhamsh
Copy link

paulhamsh commented Jan 8, 2023

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.
@paulhamsh paulhamsh added the Status: Awaiting triage Issue is waiting for triage label Jan 8, 2023
@paulhamsh paulhamsh changed the title BluetoothSerial: register_callback compile error BluetoothSerial: register_callback compile error - but I think it is probably a problem with the compiler not the BluetoothSerial library Jan 8, 2023
@fheday
Copy link

fheday commented Jan 9, 2023

I can confirm I am having the same problem after an update of platformIO.
I also had no change in the source code.

@fheday
Copy link

fheday commented Jan 9, 2023

actually I checked the code works with [email protected], but not with [email protected].

It seems that the arduino component does not works with the latest version.

me-no-dev added a commit that referenced this issue Jan 9, 2023
Fixes: #7675

The signature of `esp_spp_cb_t` has changed in recent ESP-IDF v4.4.3, so this fix targets to accomodate that change in Arduino
@me-no-dev
Copy link
Member

the signature of the callback has changed in ESP-IDF. Linked above is a PR that fixes this on our side :)

me-no-dev added a commit that referenced this issue Jan 12, 2023
Fixes: #7675

The signature of `esp_spp_cb_t` has changed in recent ESP-IDF v4.4.3, so this fix targets to accomodate that change in Arduino
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting triage Issue is waiting for triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants