Skip to content

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

Closed
@mazgch

Description

@mazgch

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;
    }
  }
  
  

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions