You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.7KB

  1. #ifndef MqttManager_h_
  2. #define MqttManager_h_
  3. #include <WiFi.h>
  4. #include <WiFiClientSecure.h>
  5. #include <PubSubClient.h>
  6. #include "WorkersList.h"
  7. class MqttManager {
  8. public:
  9. static void init(char *ssid, char *wifiPassword, char *server, int port, char *clientName, char *username, char *mqttPassword);
  10. static void init(char *ssid, char *wifiPassword, IPAddress ip, IPAddress dns, IPAddress gateway, char *server, int port, char *clientName, char *username, char *mqttPassword);
  11. static void loadCACert(char *ca);
  12. static bool connect();
  13. static bool connectWiFi();
  14. static bool disconnect();
  15. static void setEquipmentTopic(char *topic, void (*callback)(uint8_t));
  16. static void setWorkersTopic(char *topic, void (*callback)(WorkersList*));
  17. static void requestEquipment(uint8_t major, uint8_t minor);
  18. static void requestWorkers(uint8_t major, uint8_t minor);
  19. static bool loop();
  20. private:
  21. static WiFiClientSecure wifiClient;
  22. static PubSubClient client;
  23. static char *equipmentTopic;
  24. static char *workersTopic;
  25. static char *clientName;
  26. static char *username;
  27. static char *password;
  28. static char *wifiSsid;
  29. static char *wifiPassword;
  30. static IPAddress *ip;
  31. static IPAddress *dns;
  32. static IPAddress *gateway;
  33. static void (*equipmentCallback)(uint8_t equipmentNeeded);
  34. static void (*workersCallback)(WorkersList *list);
  35. static void mqttCallback(char *topic, byte *payload, unsigned int length);
  36. };
  37. #endif