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

Feature request: simple example that works #142

Open
rwb196884 opened this issue Oct 18, 2024 · 2 comments · May be fixed by #138
Open

Feature request: simple example that works #142

rwb196884 opened this issue Oct 18, 2024 · 2 comments · May be fixed by #138
Labels
enhancement New feature or request

Comments

@rwb196884
Copy link

Copied this from https://github.com/plapointe6/EspMQTTClient/blob/master/examples/SimpleMQTTClient/SimpleMQTTClient.ino
but it doesn't do anything.
Is it supposed to do something?

// Origin: https://github.com/plapointe6/EspMQTTClient/blob/master/examples/SimpleMQTTClient/SimpleMQTTClient.ino

// Doesn't work.

#include "EspMQTTClient.h"

EspMQTTClient client(
  "196883",
  "MYWIFI3520",
  "192.168.1.113",  // MQTT Broker server ip
  "",   // Can be omitted if not needed
  "",   // Can be omitted if not needed
  "ESP32",     // Client name that uniquely identify your device
  1883              // The MQTT port, default to 1883. this line can be omitted
);

void setup()
{
  Serial.begin(115200);

  client.enableDebuggingMessages(); // Enable debugging messages sent to serial output
}

void onConnectionEstablished()
{
  client.subscribe("zigbe2mqtt/Home/+/Thermostat", [](const String & topic, const String & payload) {
    Serial.println("(From wildcard) topic: " + topic + ", payload: " + payload);
  });
}

int n = 0
void loop()
{
  client.loop();
  if ( n % 1000000 == 0) {
    Serial.println(n);
  }
  n++
}
@rwb196884 rwb196884 added the enhancement New feature or request label Oct 18, 2024
@rwb196884
Copy link
Author

It's evem more fucked than I thought.

c:\GoogleDrive\My Drive\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp: In member function 'bool EspMQTTClient::handleWiFi()':
c:\GoogleDrive\My Drive\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:187:5: error: 'WiFi' was not declared in this scope
  187 |     WiFi.disconnect(true);
      |     ^~~~
c:\GoogleDrive\My Drive\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:194:27: error: 'WiFi' was not declared in this scope
  194 |   bool isWifiConnected = (WiFi.status() == WL_CONNECTED);
      |                           ^~~~
c:\GoogleDrive\My Drive\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:194:44: error: 'WL_CONNECTED' was not declared in this scope; did you mean 'MQTT_CONNECTED'?
  194 |   bool isWifiConnected = (WiFi.status() == WL_CONNECTED);
      |                                            ^~~~~~~~~~~~
      |                                            MQTT_CONNECTED
c:\GoogleDrive\My Drive\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:215:27: error: 'WL_CONNECT_FAILED' was not declared in this scope; did you mean 'MQTT_CONNECT_FAILED'?
  215 |       if(WiFi.status() == WL_CONNECT_FAILED || millis() - _lastWifiConnectiomAttemptMillis >= _wifiReconnectionAttemptDelay)
      |                           ^~~~~~~~~~~~~~~~~
      |                           MQTT_CONNECT_FAILED
c:\GoogleDrive\My Drive\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp: In member function 'bool EspMQTTClient::handleMQTT()':
c:\GoogleDrive\My Drive\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:325:9: error: 'WiFi' was not declared in this scope
  325 |         WiFi.disconnect(true);
      |         ^~~~
c:\GoogleDrive\My Drive\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp: In member function 'void EspMQTTClient::onWiFiConnectionEstablished()':
c:\GoogleDrive\My Drive\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:362:75: error: 'WiFi' was not declared in this scope
  362 |       Serial.printf("WiFi: Connected (%fs), ip : %s \n", millis()/1000.0, WiFi.localIP().toString().c_str());
      |                                                                           ^~~~
c:\GoogleDrive\My Drive\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp: In member function 'void EspMQTTClient::onWiFiConnectionLost()':
c:\GoogleDrive\My Drive\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:388:5: error: 'WiFi' was not declared in this scope
  388 |     WiFi.disconnect(true);
      |     ^~~~
c:\GoogleDrive\My Drive\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp: In member function 'void EspMQTTClient::connectToWifi()':
c:\GoogleDrive\My Drive\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:555:3: error: 'WiFi' was not declared in this scope
  555 |   WiFi.mode(WIFI_STA);
      |   ^~~~
c:\GoogleDrive\My Drive\Arduino\libraries\EspMQTTClient\src\EspMQTTClient.cpp:555:13: error: 'WIFI_STA' was not declared in this scope; did you mean 'WIFI_IF_STA'?
  555 |   WiFi.mode(WIFI_STA);
      |             ^~~~~~~~
      |             WIFI_IF_STA
Multiple libraries were found for "PubSubClient.h"
  Used: c:\GoogleDrive\My Drive\Arduino\libraries\PubSubClient
  Not used: c:\GoogleDrive\My Drive\Arduino\libraries\TBPubSubClient
Multiple libraries were found for "WiFiClient.h"
  Used: C:\Users\User\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.5\libraries\WiFi
  Not used: c:\GoogleDrive\My Drive\Arduino\libraries\WiFi
exit status 1

Compilation error: exit status 1

@entttom
Copy link

entttom commented Oct 26, 2024

look here:
#140

@per1234 per1234 linked a pull request Nov 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants