Remove "expression cannot be used as a function error" with delete pointer type esp_spp_cb_t

This commit is contained in:
torok.istvan 2025-09-26 16:28:30 +02:00
parent 0282d0741e
commit 636b31ae00
4 changed files with 17 additions and 16 deletions

View File

@ -42,7 +42,7 @@ static TaskHandle_t _spp_task_handle = NULL;
static EventGroupHandle_t _spp_event_group = NULL; static EventGroupHandle_t _spp_event_group = NULL;
static EventGroupHandle_t _bt_event_group = NULL; static EventGroupHandle_t _bt_event_group = NULL;
static boolean secondConnectionAttempt; static boolean secondConnectionAttempt;
static esp_spp_cb_t * custom_spp_callback = NULL; static esp_spp_cb_t custom_spp_callback = NULL;
static BluetoothSerialDataCb custom_data_callback = NULL; static BluetoothSerialDataCb custom_data_callback = NULL;
static esp_bd_addr_t current_bd_addr; static esp_bd_addr_t current_bd_addr;
static ConfirmRequestCb confirm_request_callback = NULL; static ConfirmRequestCb confirm_request_callback = NULL;
@ -790,7 +790,7 @@ void BluetoothSerial::confirmReply(boolean confirm)
} }
esp_err_t BluetoothSerial::register_callback(esp_spp_cb_t * callback) esp_err_t BluetoothSerial::register_callback(esp_spp_cb_t callback)
{ {
custom_spp_callback = callback; custom_spp_callback = callback;
return ESP_OK; return ESP_OK;

View File

@ -37,7 +37,7 @@ class BluetoothSerial: public Stream
void flush(); void flush();
void end(void); void end(void);
void onData(BluetoothSerialDataCb cb); void onData(BluetoothSerialDataCb cb);
esp_err_t register_callback(esp_spp_cb_t * callback); esp_err_t register_callback(esp_spp_cb_t callback);
void onConfirmRequest(ConfirmRequestCb cb); void onConfirmRequest(ConfirmRequestCb cb);
void onAuthComplete(AuthCompleteCb cb); void onAuthComplete(AuthCompleteCb cb);

View File

@ -9,7 +9,7 @@ class BTSerialInterface
virtual bool begin(String deviceName, bool isMaster, uint16_t rxQueueSize, uint16_t txQueueSize) = 0; virtual bool begin(String deviceName, bool isMaster, uint16_t rxQueueSize, uint16_t txQueueSize) = 0;
virtual void disconnect() = 0; virtual void disconnect() = 0;
virtual void end() = 0; virtual void end() = 0;
virtual esp_err_t register_callback(esp_spp_cb_t * callback) = 0; virtual esp_err_t register_callback(esp_spp_cb_t callback) = 0;
virtual void setTimeout(unsigned long timeout) = 0; virtual void setTimeout(unsigned long timeout) = 0;
virtual int available() = 0; virtual int available() = 0;
@ -44,7 +44,7 @@ class BTClassicSerial : public virtual BTSerialInterface, public BluetoothSerial
BluetoothSerial::end(); BluetoothSerial::end();
} }
esp_err_t register_callback(esp_spp_cb_t * callback) esp_err_t register_callback(esp_spp_cb_t callback)
{ {
return BluetoothSerial::register_callback(callback); return BluetoothSerial::register_callback(callback);
} }
@ -110,7 +110,7 @@ class BTLESerial : public virtual BTSerialInterface, public BleSerial
BleSerial::end(); BleSerial::end();
} }
esp_err_t register_callback(esp_spp_cb_t *callback) esp_err_t register_callback(esp_spp_cb_t callback)
{ {
connectionCallback = callback; connectionCallback = callback;
return ESP_OK; return ESP_OK;
@ -156,19 +156,20 @@ class BTLESerial : public virtual BTSerialInterface, public BleSerial
{ {
// bleConnected = true; Removed until PR is accepted // bleConnected = true; Removed until PR is accepted
if(connectionCallback){ if(connectionCallback){
connectionCallback(ESP_SPP_SRV_OPEN_EVT, nullptr); // connectionCallback(ESP_SPP_SRV_OPEN_EVT, nullptr);
} }
} }
void onDisconnect(BLEServer *pServer) void onDisconnect(BLEServer *pServer)
{ {
// bleConnected = false; Removed until PR is accepted // bleConnected = false; Removed until PR is accepted
esp_spp_cb_param_t* param = NULL;
connectionCallback(ESP_SPP_CLOSE_EVT, nullptr); connectionCallback(ESP_SPP_CLOSE_EVT, nullptr);
Server->startAdvertising(); Server->startAdvertising();
} }
private: private:
esp_spp_cb_t *connectionCallback; esp_spp_cb_t connectionCallback;
}; };
#endif #endif

View File

@ -1810,14 +1810,14 @@ void bluetoothStart()
// else if (settings.bluetoothRadioType == BLUETOOTH_RADIO_BLE) // else if (settings.bluetoothRadioType == BLUETOOTH_RADIO_BLE)
// bluetoothSerial = new BTLESerial(); // bluetoothSerial = new BTLESerial();
if (bluetoothSerial->begin(deviceName) == false) // if (bluetoothSerial->begin(deviceName) == false)
{ // {
Serial.println("An error occurred initializing Bluetooth"); // Serial.println("An error occurred initializing Bluetooth");
if (productVariant == RTK_SURVEYOR) // if (productVariant == RTK_SURVEYOR)
digitalWrite(pin_bluetoothStatusLED, LOW); // digitalWrite(pin_bluetoothStatusLED, LOW);
return; // return;
} // }
//Set PIN to 1234 so we can connect to older BT devices, but not require a PIN for modern device pairing //Set PIN to 1234 so we can connect to older BT devices, but not require a PIN for modern device pairing
//See issue: https://github.com/sparkfun/SparkFun_RTK_Firmware/issues/5 //See issue: https://github.com/sparkfun/SparkFun_RTK_Firmware/issues/5
@ -1839,7 +1839,7 @@ void bluetoothStart()
esp_bt_gap_set_pin(pin_type, 4, pin_code); esp_bt_gap_set_pin(pin_type, 4, pin_code);
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
bluetoothSerial->register_callback(bluetoothCallback); //Controls BT Status LED on Surveyor // bluetoothSerial->register_callback(bluetoothCallback); //Controls BT Status LED on Surveyor
bluetoothSerial->setTimeout(250); bluetoothSerial->setTimeout(250);
Serial.print("Bluetooth broadcasting as: "); Serial.print("Bluetooth broadcasting as: ");