mobizt / FirebaseClient

🔥Async Firebase Client for Arduino. Supports Realtime Database, Cloud Firestore Database, Firebase Storage, Cloud Messaging, Google Cloud Functions and Google Cloud Storage.
MIT License
107 stars 6 forks source link

Compilation Error: object of abstract class type "BSSL_SSL_Client" is not allowed: #145

Closed BoltSwith closed 6 hours ago

BoltSwith commented 7 hours ago

Greetings,

I had previously compiled this library on the same project (SoC is ESP32s3) using the esp-idf (with VS Code as editor) and Arduino as a Component 6 days ago. It compiled on the esp-idf version v5.1.3 successfully, however, I couldn't get an example to work ( I encountered runtime errors).

Few hours ago, I upgraded my esp-idf version to v5.3.1. And trying to compile this latest version of FirebaseClient v1.3.11 , I get the following compilation errors below:

Errors:

Supporting Messages:

The errors point to the file: FirebaseClient\src\client\SSLClient\client\BSSL_TCP_Client.h on Line - 440 (BSSL_SSL_Client _ssl_client;)

I can provide more information that may be required.

Thanks for the support/effort.

mobizt commented 6 hours ago

There is no error from cppcheck and all platforms (samd, ARM, ESP, Pico and Arduino mbed) and sdk compilation.

This is specific to your system only.

mobizt commented 6 hours ago

The BSSL_SSL_Client is the derived class from Arduino's Client (Stream) class. It overrides all based class virtual functions.

And it works normally under Arduino framework in many platforms included ARM and SAMD.

mobizt commented 6 hours ago

I think that there is something that is not compatible e.g. C++ compiler version and Arduino Core.

mobizt commented 5 hours ago

Arduino Client class virtual functions. https://github.com/espressif/arduino-esp32/blob/7018cd114d00249674567846c9d67fbb3a1240a3/cores/esp32/Client.h#L26-L45

And all are overridden in derived class. https://github.com/mobizt/FirebaseClient/blob/c2ad4bf962e355e6d3e9dcf3bf2c55bb6bc04e89/src/client/SSLClient/client/BSSL_SSL_Client.h#L93-L230

Only three functions that should override in ESP8266 Client class.

size_t peekAvailable() EMBED_SSL_ENGINE_BASE_OVERRIDE; 

const char *peekBuffer() EMBED_SSL_ENGINE_BASE_OVERRIDE; 

void peekConsume(size_t consume) EMBED_SSL_ENGINE_BASE_OVERRIDE; 

The BSSL_SSL_Client class object was defined locally here. https://github.com/mobizt/FirebaseClient/blob/c2ad4bf962e355e6d3e9dcf3bf2c55bb6bc04e89/src/client/SSLClient/client/BSSL_TCP_Client.h#L440

BoltSwith commented 4 hours ago

You're very correct.

I upgraded the Arduino core library from arduino-esp32 v3.0.4 to arduino-esp32 3.1.0-rc1 - pre-release.

The core 3.1.0-rc1 has additional virtual functions which are not yet implemented in the BSSL_SSL_Client class.

That is:


/*
 Client.h - Base class that provides Client
 Copyright (c) 2011 Adrian McEwen.  All right reserved.

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef client_h
#define client_h
#include "Print.h"
#include "Stream.h"
#include "IPAddress.h"

class Client : public Stream {
public:
  virtual int connect(IPAddress ip, uint16_t port) = 0;
  virtual int connect(IPAddress ip, uint16_t port, int32_t timeout) = 0;
  virtual int connect(const char *host, uint16_t port) = 0;
  virtual int connect(const char *host, uint16_t port, int32_t timeout) = 0;
  virtual size_t write(uint8_t) = 0;
  virtual size_t write(const uint8_t *buf, size_t size) = 0;
  virtual int available() = 0;
  virtual int read() = 0;
  virtual int read(uint8_t *buf, size_t size) = 0;
  virtual int peek() = 0;
  virtual void flush() = 0;
  virtual void stop() = 0;
  virtual uint8_t connected() = 0;
  virtual operator bool() = 0;

protected:
  uint8_t *rawIPAddress(IPAddress &addr) {
    return addr.raw_address();
  }
};

#endif

Thanks for the swift response.

mobizt commented 4 hours ago

Thanks for the useful information.

This will cause errors in all ESP32 Client derived classes in the future for this non-Arduino compatibility, and I think it is better to rename this new connect functions instead.

BoltSwith commented 3 hours ago

Yeah, true.

The error occurred in all libraries with classes that extends the Arduino Client class. I had to insert the below in the class body of all derived classes of the Client class before I could get the application to compile successfully.

    int connect(IPAddress ip, uint16_t port, int32_t timeout) override { return 0;}
    int connect(const char *host, uint16_t port, int32_t timeout) override { return 0;}