Skip to content
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

pure functions Client:connect(...., int32_t timeout) not provided by MqttClient library. #116

Open
mazgch opened this issue Jan 2, 2025 · 1 comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@mazgch
Copy link
Contributor

mazgch commented Jan 2, 2025

Compiler warnings when compiled with Ardunio, esp32 v3.1.0 and All warning enabled

The MqttClient class should provide implementation for the pure functions of the Client class

int Client::connect(IPAddress ip, uint16_t port, int32_t timeout) = 0;
int Client::connect(const char *host, uint16_t port, int32_t timeout) = 0;

probably something like this in addition to the existing interface:

int MqttClient::connect(IPAddress ip, uint16_t port, int32_t timeout)
{
  return connect(ip, NULL, port, timeout);
}

int MqttClient::connect(const char *host, uint16_t port, int32_t timeout)
{
  return connect((uint32_t)0, host, port, timeout);
}

int MqttClient::connect(IPAddress ip, const char* host, uint16_t port, int32_t timeout)
{
  if (clientConnected()) {
    _client->stop();
  }
  _rxState = MQTT_CLIENT_RX_STATE_READ_TYPE;
  _connected = false;
  _txPacketId = 0x0000;

  if (host) {
    if (!_client->connect(host, port, timeout)) {
      _connectError = MQTT_CONNECTION_REFUSED;
      return 0;
    }
  } else {
    if (!_client->connect(ip, port, timeout)) {
      _connectError = MQTT_CONNECTION_REFUSED;
      return 0;
    }
  }
  
  
@pennam
Copy link
Contributor

pennam commented Jan 7, 2025

@mazgch a fix has been proposed in the esp32 core espressif/arduino-esp32#10776

@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

3 participants