WS_MQTT.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef _WS_MQTT_H_
  2. #define _WS_MQTT_H_
  3. #include <ArduinoJson.h>
  4. // #include <Arduino.h>
  5. #include <PubSubClient.h>
  6. #include <WiFi.h>
  7. #include <WebServer.h>
  8. #include <WiFiClientSecure.h>
  9. #include "WS_GPIO.h"
  10. #include "WS_Information.h"
  11. #define MQTT_Mode 3
  12. #define WIFI_Mode 3
  13. extern PubSubClient client;
  14. extern WiFiClient espClient;
  15. extern WebServer server;
  16. extern bool Relay_Flag[6]; // Relay current status flag
  17. extern void Relay_Analysis(uint8_t *buf,uint8_t Mode_Flag);
  18. /************************************************** Web *********************************************/
  19. void handleRoot();
  20. void handleGetData();
  21. void handleSwitch(int ledNumber);
  22. void handleSwitch1();
  23. void handleSwitch2();
  24. void handleSwitch3();
  25. void handleSwitch4();
  26. void handleSwitch5();
  27. void handleSwitch6();
  28. void handleSwitch7();
  29. void handleSwitch8();
  30. /************************************************** MQTT *********************************************/
  31. void callback(char* topic, byte* payload, unsigned int length); // MQTT subscribes to callback functions for processing received messages
  32. void setup_wifi();
  33. void reconnect(); // Reconnect to the MQTT server
  34. void sendJsonData(); // Send data in JSON format to MQTT server
  35. void MQTT_Init();
  36. void MQTT_Loop();
  37. #endif