diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d108852..f9837e2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,8 +15,8 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p Please ensure to specify the following: * Arduino IDE version (e.g. 1.8.19) or Platform.io version -* Board Type (e.g. ESP32S3_DEV, ESP32S2_DEV, ESP32C3_DEV) -* Board Core Version (e.g. ESP32 core v2.0.5) +* Board Type (e.g. ESP32_DEV, ESP32S3_DEV, ESP32S2_DEV, ESP32C3_DEV) +* Board Core Version (e.g. ESP32 core v2.0.6) * Contextual information (e.g. what you were trying to achieve) * Simplest possible steps to reproduce * Anything that might be relevant in your opinion, such as: @@ -24,17 +24,18 @@ Please ensure to specify the following: * Network configuration -Please be educated, civilized and constructive. Disrespective posts against [GitHub Code of Conduct](https://docs.github.com/en/site-policy/github-terms/github-event-code-of-conduct) will be ignored and deleted. +Please be educated, civilized and constructive as you've always been. Disrespective posts against [GitHub Code of Conduct](https://docs.github.com/en/site-policy/github-terms/github-event-code-of-conduct) will be ignored and deleted. +--- ### Example ``` Arduino IDE version: 1.8.19 ESP32S3_DEV board -ESP32 core v2.0.5 +ESP32 core v2.0.6 OS: Ubuntu 20.04 LTS -Linux xy-Inspiron-3593 5.15.0-56-generic #62~20.04.1-Ubuntu SMP Tue Nov 22 21:24:20 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux +Linux xy-Inspiron-3593 5.15.0-57-generic #63~20.04.1-Ubuntu SMP Wed Nov 30 13:40:16 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux Context: I encountered a crash while using this library diff --git a/Images/W6100.png b/Images/W6100.png new file mode 100644 index 0000000..867119a Binary files /dev/null and b/Images/W6100.png differ diff --git a/changelog.md b/changelog.md index 1174554..f9c0f03 100644 --- a/changelog.md +++ b/changelog.md @@ -15,6 +15,7 @@ ## Table of Contents * [Changelog](#changelog) + * [Releases v1.10.0](#releases-v1100) * [Releases v1.9.0](#releases-v190) * [Releases v1.8.0](#releases-v180) @@ -23,6 +24,10 @@ ## Changelog +### Releases v1.10.0 + +1. Add support to `ESP32` and `ESP32S2/S3/C3` boards using `LwIP W6100 Ethernet` + ### Releases v1.9.0 1. Add support to `ESP32S2/C3` boards using `LwIP W5500 or ENC28J60 Ethernet` diff --git a/examples/ESP32_ENC/FullyFeaturedSSL_ESP32_ENC/FullyFeaturedSSL_ESP32_ENC.ino b/examples/ESP32_ENC/FullyFeaturedSSL_ESP32_ENC/FullyFeaturedSSL_ESP32_ENC.ino index 94d465f..30bceec 100644 --- a/examples/ESP32_ENC/FullyFeaturedSSL_ESP32_ENC/FullyFeaturedSSL_ESP32_ENC.ino +++ b/examples/ESP32_ENC/FullyFeaturedSSL_ESP32_ENC/FullyFeaturedSSL_ESP32_ENC.ino @@ -261,12 +261,10 @@ void setup() // start the ethernet connection and the server: // Use DHCP dynamic IP and random mac - uint16_t index = millis() % NUMBER_OF_MAC; - //bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ, // int SPI_HOST, uint8_t *ENC28J60_Mac = ENC28J60_Default_Mac); //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST ); - ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST, mac[index] ); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST, mac[millis() % NUMBER_OF_MAC] ); // Static IP, leave without this line to get IP via DHCP //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); diff --git a/examples/ESP32_ENC/FullyFeatured_ESP32_ENC/FullyFeatured_ESP32_ENC.ino b/examples/ESP32_ENC/FullyFeatured_ESP32_ENC/FullyFeatured_ESP32_ENC.ino index 0521c4f..e4f8c80 100644 --- a/examples/ESP32_ENC/FullyFeatured_ESP32_ENC/FullyFeatured_ESP32_ENC.ino +++ b/examples/ESP32_ENC/FullyFeatured_ESP32_ENC/FullyFeatured_ESP32_ENC.ino @@ -238,12 +238,10 @@ void setup() // start the ethernet connection and the server: // Use DHCP dynamic IP and random mac - uint16_t index = millis() % NUMBER_OF_MAC; - //bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ, // int SPI_HOST, uint8_t *ENC28J60_Mac = ENC28J60_Default_Mac); //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST ); - ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST, mac[index] ); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, SPI_HOST, mac[millis() % NUMBER_OF_MAC] ); // Static IP, leave without this line to get IP via DHCP //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); diff --git a/examples/ESP32_SC_ENC/FullyFeaturedSSL_ESP32_SC_ENC/FullyFeaturedSSL_ESP32_SC_ENC.ino b/examples/ESP32_SC_ENC/FullyFeaturedSSL_ESP32_SC_ENC/FullyFeaturedSSL_ESP32_SC_ENC.ino index e426ccc..bce7968 100644 --- a/examples/ESP32_SC_ENC/FullyFeaturedSSL_ESP32_SC_ENC/FullyFeaturedSSL_ESP32_SC_ENC.ino +++ b/examples/ESP32_SC_ENC/FullyFeaturedSSL_ESP32_SC_ENC/FullyFeaturedSSL_ESP32_SC_ENC.ino @@ -264,12 +264,10 @@ void setup() // start the ethernet connection and the server: // Use DHCP dynamic IP and random mac - uint16_t index = millis() % NUMBER_OF_MAC; - //bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ, // int SPI_HOST, uint8_t *ENC28J60_Mac = ENC28J60_Default_Mac); //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST ); - ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[index] ); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[millis() % NUMBER_OF_MAC] ); // Static IP, leave without this line to get IP via DHCP //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); diff --git a/examples/ESP32_SC_ENC/FullyFeatured_ESP32_SC_ENC/FullyFeatured_ESP32_SC_ENC.ino b/examples/ESP32_SC_ENC/FullyFeatured_ESP32_SC_ENC/FullyFeatured_ESP32_SC_ENC.ino index 9ca15b5..79890da 100644 --- a/examples/ESP32_SC_ENC/FullyFeatured_ESP32_SC_ENC/FullyFeatured_ESP32_SC_ENC.ino +++ b/examples/ESP32_SC_ENC/FullyFeatured_ESP32_SC_ENC/FullyFeatured_ESP32_SC_ENC.ino @@ -239,12 +239,10 @@ void setup() // start the ethernet connection and the server: // Use DHCP dynamic IP and random mac - uint16_t index = millis() % NUMBER_OF_MAC; - //bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ, // int SPI_HOST, uint8_t *ENC28J60_Mac = ENC28J60_Default_Mac); //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST ); - ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[index] ); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[millis() % NUMBER_OF_MAC] ); // Static IP, leave without this line to get IP via DHCP //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); diff --git a/examples/ESP32_SC_W5500/FullyFeaturedSSL_ESP32_SC_W5500/FullyFeaturedSSL_ESP32_SC_W5500.ino b/examples/ESP32_SC_W5500/FullyFeaturedSSL_ESP32_SC_W5500/FullyFeaturedSSL_ESP32_SC_W5500.ino index b2a8c16..a04fba8 100644 --- a/examples/ESP32_SC_W5500/FullyFeaturedSSL_ESP32_SC_W5500/FullyFeaturedSSL_ESP32_SC_W5500.ino +++ b/examples/ESP32_SC_W5500/FullyFeaturedSSL_ESP32_SC_W5500/FullyFeaturedSSL_ESP32_SC_W5500.ino @@ -264,12 +264,10 @@ void setup() // start the ethernet connection and the server: // Use DHCP dynamic IP and random mac - uint16_t index = millis() % NUMBER_OF_MAC; - //bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ, // int SPI_HOST, uint8_t *W5500_Mac = W5500_Default_Mac); - //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST ); - ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[index] ); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST ); + //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[millis() % NUMBER_OF_MAC] ); // Static IP, leave without this line to get IP via DHCP //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); diff --git a/examples/ESP32_SC_W5500/FullyFeatured_ESP32_SC_W5500/FullyFeatured_ESP32_SC_W5500.ino b/examples/ESP32_SC_W5500/FullyFeatured_ESP32_SC_W5500/FullyFeatured_ESP32_SC_W5500.ino index cf98a30..acaff71 100644 --- a/examples/ESP32_SC_W5500/FullyFeatured_ESP32_SC_W5500/FullyFeatured_ESP32_SC_W5500.ino +++ b/examples/ESP32_SC_W5500/FullyFeatured_ESP32_SC_W5500/FullyFeatured_ESP32_SC_W5500.ino @@ -239,12 +239,10 @@ void setup() // start the ethernet connection and the server: // Use DHCP dynamic IP and random mac - uint16_t index = millis() % NUMBER_OF_MAC; - //bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ, // int SPI_HOST, uint8_t *W5500_Mac = W5500_Default_Mac); - //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST ); - ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[index] ); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST ); + //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[millis() % NUMBER_OF_MAC] ); // Static IP, leave without this line to get IP via DHCP //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); diff --git a/examples/ESP32_SC_W6100/FullyFeaturedSSL_ESP32_SC_W6100/FullyFeaturedSSL_ESP32_SC_W6100.ino b/examples/ESP32_SC_W6100/FullyFeaturedSSL_ESP32_SC_W6100/FullyFeaturedSSL_ESP32_SC_W6100.ino new file mode 100644 index 0000000..a9f294d --- /dev/null +++ b/examples/ESP32_SC_W6100/FullyFeaturedSSL_ESP32_SC_W6100/FullyFeaturedSSL_ESP32_SC_W6100.ino @@ -0,0 +1,283 @@ +/**************************************************************************************************************************** + FullyFeatureSSL_ESP32_SC_W6100.ino + + AsyncMQTT_ESP32 is a library for ESP32 boards using WiFi or LwIP W6100 / W6100 / ENC28J60 / LAN8720 Ethernet + + Based on and modified from : + + 1) async-mqtt-client (https://github.com/marvinroger/async-mqtt-client) + 2) AsyncMQTT_Generic (https://github.com/khoih-prog/AsyncMQTT_Generic) + + Built by Khoi Hoang https://github.com/khoih-prog/AsyncMQTT_ESP32 + *****************************************************************************************************************************/ + +#include "defines.h" + +extern "C" +{ +#include "freertos/FreeRTOS.h" +#include "freertos/timers.h" +} + +#define ASYNC_TCP_SSL_ENABLED true +//#define ASYNC_TCP_SSL_ENABLED false + +#include + +//#define MQTT_HOST IPAddress(192, 168, 2, 110) +#define MQTT_HOST "broker.emqx.io" // Broker address + +#if ASYNC_TCP_SSL_ENABLED + +#define MQTT_SECURE true + +const uint8_t MQTT_SERVER_FINGERPRINT[] = {0x7e, 0x36, 0x22, 0x01, 0xf9, 0x7e, 0x99, 0x2f, 0xc5, 0xdb, 0x3d, 0xbe, 0xac, 0x48, 0x67, 0x5b, 0x5d, 0x47, 0x94, 0xd2}; +const char *PubTopic = "async-mqtt/ESP32_W6100_SSL_Pub"; // Topic to publish + +#define MQTT_PORT 8883 + +#else + +const char *PubTopic = "async-mqtt/ESP32_SC_W6100_Pub"; // Topic to publish + +#define MQTT_PORT 1883 + +#endif + +AsyncMqttClient mqttClient; +TimerHandle_t mqttReconnectTimer; + +void connectToMqtt() +{ + Serial.println("Connecting to MQTT..."); + mqttClient.connect(); +} + +void ETH_event(WiFiEvent_t event) +{ + switch (event) + { +#if USING_CORE_ESP32_CORE_V200_PLUS + + case ARDUINO_EVENT_ETH_START: + Serial.println("ETH starting"); + break; + + case ARDUINO_EVENT_ETH_CONNECTED: + Serial.println("ETH connected"); + break; + + case ARDUINO_EVENT_ETH_GOT_IP: + Serial.println("ETH got IP"); + Serial.print("IP address: "); + Serial.println(ETH.localIP()); + connectToMqtt(); + break; + + case ARDUINO_EVENT_ETH_DISCONNECTED: + Serial.println("ETH lost connection"); + + // ensure we don't reconnect to MQTT when no ETH + xTimerStop(mqttReconnectTimer, 0); + + break; + + case ARDUINO_EVENT_ETH_STOP: + Serial.println("ETH stops"); + + // ensure we don't reconnect to MQTT when no ETH + xTimerStop(mqttReconnectTimer, 0); + + break; +#else + + case SYSTEM_EVENT_ETH_CONNECTED: + erial.println(F("ETH Connected")); + break; + + case SYSTEM_EVENT_ETH_GOT_IP: + Serial.println("ETH connected"); + Serial.println("IP address: "); + Serial.println(ETH.localIP()); + connectToMqtt(); + break; + + case SYSTEM_EVENT_ETH_DISCONNECTED: + case SYSTEM_EVENT_ETH_STOP: + Serial.println("ETH lost connection"); + + // ensure we don't reconnect to MQTT when no ETH + xTimerStop(mqttReconnectTimer, 0); + + break; +#endif + + default: + break; + } +} + +void printSeparationLine() +{ + Serial.println("************************************************"); +} + +void onMqttConnect(bool sessionPresent) +{ + Serial.print("Connected to MQTT broker: "); + Serial.print(MQTT_HOST); + Serial.print(", port: "); + Serial.println(MQTT_PORT); + Serial.print("PubTopic: "); + Serial.println(PubTopic); + + printSeparationLine(); + Serial.print("Session present: "); + Serial.println(sessionPresent); + + uint16_t packetIdSub = mqttClient.subscribe(PubTopic, 2); + Serial.print("Subscribing at QoS 2, packetId: "); + Serial.println(packetIdSub); + + mqttClient.publish(PubTopic, 0, true, "ESP32_W6100 Test"); + Serial.println("Publishing at QoS 0"); + + uint16_t packetIdPub1 = mqttClient.publish(PubTopic, 1, true, "test 2"); + Serial.print("Publishing at QoS 1, packetId: "); + Serial.println(packetIdPub1); + + uint16_t packetIdPub2 = mqttClient.publish(PubTopic, 2, true, "test 3"); + Serial.print("Publishing at QoS 2, packetId: "); + Serial.println(packetIdPub2); + + printSeparationLine(); +} + +void onMqttDisconnect(AsyncMqttClientDisconnectReason reason) +{ + (void) reason; + + Serial.println("Disconnected from MQTT."); + + if (ESP32_W6100_isConnected()) + { + xTimerStart(mqttReconnectTimer, 0); + } +} + +void onMqttSubscribe(const uint16_t& packetId, const uint8_t& qos) +{ + Serial.println("Subscribe acknowledged."); + Serial.print(" packetId: "); + Serial.println(packetId); + Serial.print(" qos: "); + Serial.println(qos); +} + +void onMqttUnsubscribe(const uint16_t& packetId) +{ + Serial.println("Unsubscribe acknowledged."); + Serial.print(" packetId: "); + Serial.println(packetId); +} + +void onMqttMessage(char* topic, char* payload, const AsyncMqttClientMessageProperties& properties, + const size_t& len, const size_t& index, const size_t& total) +{ + (void) payload; + + Serial.println("Publish received."); + Serial.print(" topic: "); + Serial.println(topic); + Serial.print(" qos: "); + Serial.println(properties.qos); + Serial.print(" dup: "); + Serial.println(properties.dup); + Serial.print(" retain: "); + Serial.println(properties.retain); + Serial.print(" len: "); + Serial.println(len); + Serial.print(" index: "); + Serial.println(index); + Serial.print(" total: "); + Serial.println(total); +} + +void onMqttPublish(const uint16_t& packetId) +{ + Serial.println("Publish acknowledged"); + Serial.print(" packetId: "); + Serial.println(packetId); +} + +void setup() +{ + Serial.begin(115200); + + while (!Serial && millis() < 5000); + + delay(500); + + Serial.print("\nStarting FullyFeatureSSL_ESP32_SC_W6100 on "); + Serial.print(ARDUINO_BOARD); + Serial.println(" with " + String(SHIELD_TYPE)); + Serial.println(WEBSERVER_ESP32_SC_W6100_VERSION); + Serial.println(ASYNC_MQTT_ESP32_VERSION); + + AMQTT_LOGWARN(F("Default SPI pinout:")); + AMQTT_LOGWARN1(F("SPI_HOST:"), ETH_SPI_HOST); + AMQTT_LOGWARN1(F("MOSI:"), MOSI_GPIO); + AMQTT_LOGWARN1(F("MISO:"), MISO_GPIO); + AMQTT_LOGWARN1(F("SCK:"), SCK_GPIO); + AMQTT_LOGWARN1(F("CS:"), CS_GPIO); + AMQTT_LOGWARN1(F("INT:"), INT_GPIO); + AMQTT_LOGWARN1(F("SPI Clock (MHz):"), SPI_CLOCK_MHZ); + AMQTT_LOGWARN(F("=========================")); + + mqttReconnectTimer = xTimerCreate("mqttTimer", pdMS_TO_TICKS(2000), pdFALSE, (void*)0, + reinterpret_cast(connectToMqtt)); + + mqttClient.onConnect(onMqttConnect); + mqttClient.onDisconnect(onMqttDisconnect); + mqttClient.onSubscribe(onMqttSubscribe); + mqttClient.onUnsubscribe(onMqttUnsubscribe); + mqttClient.onMessage(onMqttMessage); + mqttClient.onPublish(onMqttPublish); + + mqttClient.setServer(MQTT_HOST, MQTT_PORT); + +#if ASYNC_TCP_SSL_ENABLED + mqttClient.setSecure(MQTT_SECURE); + + if (MQTT_SECURE) + { + //mqttClient.addServerFingerprint((const uint8_t[])MQTT_SERVER_FINGERPRINT); + mqttClient.addServerFingerprint((const uint8_t *)MQTT_SERVER_FINGERPRINT); + } + +#endif + + /////////////////////////////////// + + // To be called before ETH.begin() + WiFi.onEvent(ETH_event); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + //bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ, + // int SPI_HOST, uint8_t *W6100_Mac = W6100_Default_Mac); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST ); + //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[millis() % NUMBER_OF_MAC] ); + + // Static IP, leave without this line to get IP via DHCP + //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); + //ETH.config(myIP, myGW, mySN, myDNS); + + ESP32_W6100_waitForConnect(); + + /////////////////////////////////// +} + +void loop() +{ +} diff --git a/examples/ESP32_SC_W6100/FullyFeaturedSSL_ESP32_SC_W6100/defines.h b/examples/ESP32_SC_W6100/FullyFeaturedSSL_ESP32_SC_W6100/defines.h new file mode 100644 index 0000000..10a64b5 --- /dev/null +++ b/examples/ESP32_SC_W6100/FullyFeaturedSSL_ESP32_SC_W6100/defines.h @@ -0,0 +1,90 @@ +/**************************************************************************************************************************** + defines.h + AsyncMQTT_ESP32 is a library for ESP32 boards using WiFi or LwIP W5500 / W6100 / ENC28J60 / LAN8720 Ethernet + + Based on and modified from : + + 1) async-mqtt-client (https://github.com/marvinroger/async-mqtt-client) + 2) AsyncMQTT_Generic (https://github.com/khoih-prog/AsyncMQTT_Generic) + + Built by Khoi Hoang https://github.com/khoih-prog/AsyncMQTT_ESP32 + ***************************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +// Debug Level from 0 to 4 +#define _ETHERNET_WEBSERVER_LOGLEVEL_ 1 +#define _ASYNC_MQTT_LOGLEVEL_ 1 + +////////////////////////////////////////////////////////// + +// For ESP32-S3 +// Optional values to override default settings +//#define ETH_SPI_HOST SPI2_HOST +//#define SPI_CLOCK_MHZ 25 + +// Must connect INT to GPIOxx or not working +//#define INT_GPIO 4 + +//#define MISO_GPIO 13 +//#define MOSI_GPIO 11 +//#define SCK_GPIO 12 +//#define CS_GPIO 10 + +// For ESP32_C3 +// Optional values to override default settings +// Don't change unless you know what you're doing +//#define ETH_SPI_HOST SPI2_HOST +//#define SPI_CLOCK_MHZ 25 + +// Must connect INT to GPIOxx or not working +//#define INT_GPIO 10 + +//#define MISO_GPIO 5 +//#define MOSI_GPIO 6 +//#define SCK_GPIO 4 +//#define CS_GPIO 7 + +////////////////////////////////////////////////////////// + +#include + +///////////////////////////////////////////// + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +// Select the IP address according to your local network +IPAddress myIP(192, 168, 2, 232); +IPAddress myGW(192, 168, 2, 1); +IPAddress mySN(255, 255, 255, 0); + +// Google DNS Server IP +IPAddress myDNS(8, 8, 8, 8); + +#endif //defines_h diff --git a/examples/ESP32_SC_W6100/FullyFeatured_ESP32_SC_W6100/FullyFeatured_ESP32_SC_W6100.ino b/examples/ESP32_SC_W6100/FullyFeatured_ESP32_SC_W6100/FullyFeatured_ESP32_SC_W6100.ino new file mode 100644 index 0000000..f952a3b --- /dev/null +++ b/examples/ESP32_SC_W6100/FullyFeatured_ESP32_SC_W6100/FullyFeatured_ESP32_SC_W6100.ino @@ -0,0 +1,258 @@ +/**************************************************************************************************************************** + FullyFeature_ESP32_SC_W6100.ino + + AsyncMQTT_ESP32 is a library for ESP32 boards using WiFi or LwIP W6100 / W6100 / ENC28J60 / LAN8720 Ethernet + + Based on and modified from : + + 1) async-mqtt-client (https://github.com/marvinroger/async-mqtt-client) + 2) AsyncMQTT_Generic (https://github.com/khoih-prog/AsyncMQTT_Generic) + + Built by Khoi Hoang https://github.com/khoih-prog/AsyncMQTT_ESP32 + *****************************************************************************************************************************/ +/* + This example uses FreeRTOS softwaretimers as there is no built-in Ticker library +*/ + +#include "defines.h" + +extern "C" +{ +#include "freertos/FreeRTOS.h" +#include "freertos/timers.h" +} + +#include + +//#define MQTT_HOST IPAddress(192, 168, 2, 110) +#define MQTT_HOST "broker.emqx.io" // Broker address +#define MQTT_PORT 1883 + +const char *PubTopic = "async-mqtt/ESP32_SC_W6100_Pub"; // Topic to publish + +AsyncMqttClient mqttClient; +TimerHandle_t mqttReconnectTimer; + +void connectToMqtt() +{ + Serial.println("Connecting to MQTT..."); + mqttClient.connect(); +} + +void ETH_event(WiFiEvent_t event) +{ + switch (event) + { +#if USING_CORE_ESP32_CORE_V200_PLUS + + case ARDUINO_EVENT_ETH_START: + Serial.println("ETH starting"); + break; + + case ARDUINO_EVENT_ETH_CONNECTED: + Serial.println("ETH connected"); + break; + + case ARDUINO_EVENT_ETH_GOT_IP: + Serial.println("ETH got IP"); + Serial.print("IP address: "); + Serial.println(ETH.localIP()); + connectToMqtt(); + break; + + case ARDUINO_EVENT_ETH_DISCONNECTED: + Serial.println("ETH lost connection"); + + // ensure we don't reconnect to MQTT when no ETH + xTimerStop(mqttReconnectTimer, 0); + + break; + + case ARDUINO_EVENT_ETH_STOP: + Serial.println("ETH stops"); + + // ensure we don't reconnect to MQTT when no ETH + xTimerStop(mqttReconnectTimer, 0); + + break; +#else + + case SYSTEM_EVENT_ETH_CONNECTED: + erial.println(F("ETH Connected")); + break; + + case SYSTEM_EVENT_ETH_GOT_IP: + Serial.println("ETH connected"); + Serial.println("IP address: "); + Serial.println(ETH.localIP()); + connectToMqtt(); + break; + + case SYSTEM_EVENT_ETH_DISCONNECTED: + case SYSTEM_EVENT_ETH_STOP: + Serial.println("ETH lost connection"); + + // ensure we don't reconnect to MQTT when no ETH + xTimerStop(mqttReconnectTimer, 0); + + break; +#endif + + default: + break; + } +} + +void printSeparationLine() +{ + Serial.println("************************************************"); +} + +void onMqttConnect(bool sessionPresent) +{ + Serial.print("Connected to MQTT broker: "); + Serial.print(MQTT_HOST); + Serial.print(", port: "); + Serial.println(MQTT_PORT); + Serial.print("PubTopic: "); + Serial.println(PubTopic); + + printSeparationLine(); + Serial.print("Session present: "); + Serial.println(sessionPresent); + + uint16_t packetIdSub = mqttClient.subscribe(PubTopic, 2); + Serial.print("Subscribing at QoS 2, packetId: "); + Serial.println(packetIdSub); + + mqttClient.publish(PubTopic, 0, true, "ESP32_W6100 Test"); + Serial.println("Publishing at QoS 0"); + + uint16_t packetIdPub1 = mqttClient.publish(PubTopic, 1, true, "test 2"); + Serial.print("Publishing at QoS 1, packetId: "); + Serial.println(packetIdPub1); + + uint16_t packetIdPub2 = mqttClient.publish(PubTopic, 2, true, "test 3"); + Serial.print("Publishing at QoS 2, packetId: "); + Serial.println(packetIdPub2); + + printSeparationLine(); +} + +void onMqttDisconnect(AsyncMqttClientDisconnectReason reason) +{ + (void) reason; + + Serial.println("Disconnected from MQTT."); + + if (ESP32_W6100_isConnected()) + { + xTimerStart(mqttReconnectTimer, 0); + } +} + +void onMqttSubscribe(const uint16_t& packetId, const uint8_t& qos) +{ + Serial.println("Subscribe acknowledged."); + Serial.print(" packetId: "); + Serial.println(packetId); + Serial.print(" qos: "); + Serial.println(qos); +} + +void onMqttUnsubscribe(const uint16_t& packetId) +{ + Serial.println("Unsubscribe acknowledged."); + Serial.print(" packetId: "); + Serial.println(packetId); +} + +void onMqttMessage(char* topic, char* payload, const AsyncMqttClientMessageProperties& properties, + const size_t& len, const size_t& index, const size_t& total) +{ + (void) payload; + + Serial.println("Publish received."); + Serial.print(" topic: "); + Serial.println(topic); + Serial.print(" qos: "); + Serial.println(properties.qos); + Serial.print(" dup: "); + Serial.println(properties.dup); + Serial.print(" retain: "); + Serial.println(properties.retain); + Serial.print(" len: "); + Serial.println(len); + Serial.print(" index: "); + Serial.println(index); + Serial.print(" total: "); + Serial.println(total); +} + +void onMqttPublish(const uint16_t& packetId) +{ + Serial.println("Publish acknowledged."); + Serial.print(" packetId: "); + Serial.println(packetId); +} + +void setup() +{ + Serial.begin(115200); + + while (!Serial && millis() < 5000); + + delay(500); + + Serial.print("\nStarting FullyFeature_ESP32_SC_W6100 on "); + Serial.print(ARDUINO_BOARD); + Serial.println(" with " + String(SHIELD_TYPE)); + Serial.println(WEBSERVER_ESP32_SC_W6100_VERSION); + Serial.println(ASYNC_MQTT_ESP32_VERSION); + + AMQTT_LOGWARN(F("Default SPI pinout:")); + AMQTT_LOGWARN1(F("SPI_HOST:"), ETH_SPI_HOST); + AMQTT_LOGWARN1(F("MOSI:"), MOSI_GPIO); + AMQTT_LOGWARN1(F("MISO:"), MISO_GPIO); + AMQTT_LOGWARN1(F("SCK:"), SCK_GPIO); + AMQTT_LOGWARN1(F("CS:"), CS_GPIO); + AMQTT_LOGWARN1(F("INT:"), INT_GPIO); + AMQTT_LOGWARN1(F("SPI Clock (MHz):"), SPI_CLOCK_MHZ); + AMQTT_LOGWARN(F("=========================")); + + mqttReconnectTimer = xTimerCreate("mqttTimer", pdMS_TO_TICKS(2000), pdFALSE, (void*)0, + reinterpret_cast(connectToMqtt)); + + mqttClient.onConnect(onMqttConnect); + mqttClient.onDisconnect(onMqttDisconnect); + mqttClient.onSubscribe(onMqttSubscribe); + mqttClient.onUnsubscribe(onMqttUnsubscribe); + mqttClient.onMessage(onMqttMessage); + mqttClient.onPublish(onMqttPublish); + + mqttClient.setServer(MQTT_HOST, MQTT_PORT); + + /////////////////////////////////// + + // To be called before ETH.begin() + WiFi.onEvent(ETH_event); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + //bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ, + // int SPI_HOST, uint8_t *W6100_Mac = W6100_Default_Mac); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST ); + //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[millis() % NUMBER_OF_MAC] ); + + // Static IP, leave without this line to get IP via DHCP + //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); + //ETH.config(myIP, myGW, mySN, myDNS); + + ESP32_W6100_waitForConnect(); + + /////////////////////////////////// +} + +void loop() +{ +} diff --git a/examples/ESP32_SC_W6100/FullyFeatured_ESP32_SC_W6100/defines.h b/examples/ESP32_SC_W6100/FullyFeatured_ESP32_SC_W6100/defines.h new file mode 100644 index 0000000..10a64b5 --- /dev/null +++ b/examples/ESP32_SC_W6100/FullyFeatured_ESP32_SC_W6100/defines.h @@ -0,0 +1,90 @@ +/**************************************************************************************************************************** + defines.h + AsyncMQTT_ESP32 is a library for ESP32 boards using WiFi or LwIP W5500 / W6100 / ENC28J60 / LAN8720 Ethernet + + Based on and modified from : + + 1) async-mqtt-client (https://github.com/marvinroger/async-mqtt-client) + 2) AsyncMQTT_Generic (https://github.com/khoih-prog/AsyncMQTT_Generic) + + Built by Khoi Hoang https://github.com/khoih-prog/AsyncMQTT_ESP32 + ***************************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +// Debug Level from 0 to 4 +#define _ETHERNET_WEBSERVER_LOGLEVEL_ 1 +#define _ASYNC_MQTT_LOGLEVEL_ 1 + +////////////////////////////////////////////////////////// + +// For ESP32-S3 +// Optional values to override default settings +//#define ETH_SPI_HOST SPI2_HOST +//#define SPI_CLOCK_MHZ 25 + +// Must connect INT to GPIOxx or not working +//#define INT_GPIO 4 + +//#define MISO_GPIO 13 +//#define MOSI_GPIO 11 +//#define SCK_GPIO 12 +//#define CS_GPIO 10 + +// For ESP32_C3 +// Optional values to override default settings +// Don't change unless you know what you're doing +//#define ETH_SPI_HOST SPI2_HOST +//#define SPI_CLOCK_MHZ 25 + +// Must connect INT to GPIOxx or not working +//#define INT_GPIO 10 + +//#define MISO_GPIO 5 +//#define MOSI_GPIO 6 +//#define SCK_GPIO 4 +//#define CS_GPIO 7 + +////////////////////////////////////////////////////////// + +#include + +///////////////////////////////////////////// + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +// Select the IP address according to your local network +IPAddress myIP(192, 168, 2, 232); +IPAddress myGW(192, 168, 2, 1); +IPAddress mySN(255, 255, 255, 0); + +// Google DNS Server IP +IPAddress myDNS(8, 8, 8, 8); + +#endif //defines_h diff --git a/examples/ESP32_W5500/FullyFeaturedSSL_ESP32_W5500/FullyFeaturedSSL_ESP32_W5500.ino b/examples/ESP32_W5500/FullyFeaturedSSL_ESP32_W5500/FullyFeaturedSSL_ESP32_W5500.ino index 1f177a8..40c0636 100644 --- a/examples/ESP32_W5500/FullyFeaturedSSL_ESP32_W5500/FullyFeaturedSSL_ESP32_W5500.ino +++ b/examples/ESP32_W5500/FullyFeaturedSSL_ESP32_W5500/FullyFeaturedSSL_ESP32_W5500.ino @@ -262,12 +262,10 @@ void setup() // start the ethernet connection and the server: // Use DHCP dynamic IP and random mac - uint16_t index = millis() % NUMBER_OF_MAC; - //bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ, // int SPI_HOST, uint8_t *W5500_Mac = W5500_Default_Mac); - //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST ); - ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[index] ); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST ); + //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[millis() % NUMBER_OF_MAC] ); // Static IP, leave without this line to get IP via DHCP //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); diff --git a/examples/ESP32_W5500/FullyFeatured_ESP32_W5500/FullyFeatured_ESP32_W5500.ino b/examples/ESP32_W5500/FullyFeatured_ESP32_W5500/FullyFeatured_ESP32_W5500.ino index 4b8385c..35b9dc3 100644 --- a/examples/ESP32_W5500/FullyFeatured_ESP32_W5500/FullyFeatured_ESP32_W5500.ino +++ b/examples/ESP32_W5500/FullyFeatured_ESP32_W5500/FullyFeatured_ESP32_W5500.ino @@ -239,12 +239,10 @@ void setup() // start the ethernet connection and the server: // Use DHCP dynamic IP and random mac - uint16_t index = millis() % NUMBER_OF_MAC; - //bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ, // int SPI_HOST, uint8_t *W5500_Mac = W5500_Default_Mac); - //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST ); - ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[index] ); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST ); + //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[millis() % NUMBER_OF_MAC] ); // Static IP, leave without this line to get IP via DHCP //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); diff --git a/examples/ESP32_W6100/FullyFeaturedSSL_ESP32_W6100/FullyFeaturedSSL_ESP32_W6100.ino b/examples/ESP32_W6100/FullyFeaturedSSL_ESP32_W6100/FullyFeaturedSSL_ESP32_W6100.ino new file mode 100644 index 0000000..ad75247 --- /dev/null +++ b/examples/ESP32_W6100/FullyFeaturedSSL_ESP32_W6100/FullyFeaturedSSL_ESP32_W6100.ino @@ -0,0 +1,281 @@ +/**************************************************************************************************************************** + FullyFeatureSSL_ESP32_W6100.ino + + AsyncMQTT_ESP32 is a library for ESP32 boards using WiFi or LwIP W6100 / W6100 / ENC28J60 / LAN8720 Ethernet + + Based on and modified from : + + 1) async-mqtt-client (https://github.com/marvinroger/async-mqtt-client) + 2) AsyncMQTT_Generic (https://github.com/khoih-prog/AsyncMQTT_Generic) + + Built by Khoi Hoang https://github.com/khoih-prog/AsyncMQTT_ESP32 + *****************************************************************************************************************************/ + +#include "defines.h" + +extern "C" +{ +#include "freertos/FreeRTOS.h" +#include "freertos/timers.h" +} + +#define ASYNC_TCP_SSL_ENABLED true +//#define ASYNC_TCP_SSL_ENABLED false + +#include + +//#define MQTT_HOST IPAddress(192, 168, 2, 110) +#define MQTT_HOST "broker.emqx.io" // Broker address + +#if ASYNC_TCP_SSL_ENABLED + +#define MQTT_SECURE true + +const uint8_t MQTT_SERVER_FINGERPRINT[] = {0x7e, 0x36, 0x22, 0x01, 0xf9, 0x7e, 0x99, 0x2f, 0xc5, 0xdb, 0x3d, 0xbe, 0xac, 0x48, 0x67, 0x5b, 0x5d, 0x47, 0x94, 0xd2}; +const char *PubTopic = "async-mqtt/ESP32_W6100_SSL_Pub"; // Topic to publish + +#define MQTT_PORT 8883 + +#else + +const char *PubTopic = "async-mqtt/ESP32_W6100_Pub"; // Topic to publish + +#define MQTT_PORT 1883 + +#endif + +AsyncMqttClient mqttClient; +TimerHandle_t mqttReconnectTimer; + +void connectToMqtt() +{ + Serial.println("Connecting to MQTT..."); + mqttClient.connect(); +} + +void ETH_event(WiFiEvent_t event) +{ + switch (event) + { +#if USING_CORE_ESP32_CORE_V200_PLUS + + case ARDUINO_EVENT_ETH_START: + Serial.println("ETH starting"); + break; + + case ARDUINO_EVENT_ETH_CONNECTED: + Serial.println("ETH connected"); + break; + + case ARDUINO_EVENT_ETH_GOT_IP: + Serial.println("ETH got IP"); + Serial.print("IP address: "); + Serial.println(ETH.localIP()); + connectToMqtt(); + break; + + case ARDUINO_EVENT_ETH_DISCONNECTED: + Serial.println("ETH lost connection"); + + // ensure we don't reconnect to MQTT when no ETH + xTimerStop(mqttReconnectTimer, 0); + + break; + + case ARDUINO_EVENT_ETH_STOP: + Serial.println("ETH stops"); + + // ensure we don't reconnect to MQTT when no ETH + xTimerStop(mqttReconnectTimer, 0); + + break; +#else + + case SYSTEM_EVENT_ETH_CONNECTED: + erial.println(F("ETH Connected")); + break; + + case SYSTEM_EVENT_ETH_GOT_IP: + Serial.println("ETH connected"); + Serial.println("IP address: "); + Serial.println(ETH.localIP()); + connectToMqtt(); + break; + + case SYSTEM_EVENT_ETH_DISCONNECTED: + case SYSTEM_EVENT_ETH_STOP: + Serial.println("ETH lost connection"); + + // ensure we don't reconnect to MQTT when no ETH + xTimerStop(mqttReconnectTimer, 0); + + break; +#endif + + default: + break; + } +} + +void printSeparationLine() +{ + Serial.println("************************************************"); +} + +void onMqttConnect(bool sessionPresent) +{ + Serial.print("Connected to MQTT broker: "); + Serial.print(MQTT_HOST); + Serial.print(", port: "); + Serial.println(MQTT_PORT); + Serial.print("PubTopic: "); + Serial.println(PubTopic); + + printSeparationLine(); + Serial.print("Session present: "); + Serial.println(sessionPresent); + + uint16_t packetIdSub = mqttClient.subscribe(PubTopic, 2); + Serial.print("Subscribing at QoS 2, packetId: "); + Serial.println(packetIdSub); + + mqttClient.publish(PubTopic, 0, true, "ESP32_W6100 Test"); + Serial.println("Publishing at QoS 0"); + + uint16_t packetIdPub1 = mqttClient.publish(PubTopic, 1, true, "test 2"); + Serial.print("Publishing at QoS 1, packetId: "); + Serial.println(packetIdPub1); + + uint16_t packetIdPub2 = mqttClient.publish(PubTopic, 2, true, "test 3"); + Serial.print("Publishing at QoS 2, packetId: "); + Serial.println(packetIdPub2); + + printSeparationLine(); +} + +void onMqttDisconnect(AsyncMqttClientDisconnectReason reason) +{ + (void) reason; + + Serial.println("Disconnected from MQTT."); + + if (ESP32_W6100_isConnected()) + { + xTimerStart(mqttReconnectTimer, 0); + } +} + +void onMqttSubscribe(const uint16_t& packetId, const uint8_t& qos) +{ + Serial.println("Subscribe acknowledged."); + Serial.print(" packetId: "); + Serial.println(packetId); + Serial.print(" qos: "); + Serial.println(qos); +} + +void onMqttUnsubscribe(const uint16_t& packetId) +{ + Serial.println("Unsubscribe acknowledged."); + Serial.print(" packetId: "); + Serial.println(packetId); +} + +void onMqttMessage(char* topic, char* payload, const AsyncMqttClientMessageProperties& properties, + const size_t& len, const size_t& index, const size_t& total) +{ + (void) payload; + + Serial.println("Publish received."); + Serial.print(" topic: "); + Serial.println(topic); + Serial.print(" qos: "); + Serial.println(properties.qos); + Serial.print(" dup: "); + Serial.println(properties.dup); + Serial.print(" retain: "); + Serial.println(properties.retain); + Serial.print(" len: "); + Serial.println(len); + Serial.print(" index: "); + Serial.println(index); + Serial.print(" total: "); + Serial.println(total); +} + +void onMqttPublish(const uint16_t& packetId) +{ + Serial.println("Publish acknowledged"); + Serial.print(" packetId: "); + Serial.println(packetId); +} + +void setup() +{ + Serial.begin(115200); + + while (!Serial && millis() < 5000); + + Serial.print("\nStarting FullyFeatureSSL_ESP32_W6100 on "); + Serial.print(ARDUINO_BOARD); + Serial.println(" with " + String(SHIELD_TYPE)); + Serial.println(WEBSERVER_ESP32_W6100_VERSION); + Serial.println(ASYNC_MQTT_ESP32_VERSION); + + AMQTT_LOGWARN(F("Default SPI pinout:")); + AMQTT_LOGWARN1(F("SPI_HOST:"), ETH_SPI_HOST); + AMQTT_LOGWARN1(F("MOSI:"), MOSI_GPIO); + AMQTT_LOGWARN1(F("MISO:"), MISO_GPIO); + AMQTT_LOGWARN1(F("SCK:"), SCK_GPIO); + AMQTT_LOGWARN1(F("CS:"), CS_GPIO); + AMQTT_LOGWARN1(F("INT:"), INT_GPIO); + AMQTT_LOGWARN1(F("SPI Clock (MHz):"), SPI_CLOCK_MHZ); + AMQTT_LOGWARN(F("=========================")); + + mqttReconnectTimer = xTimerCreate("mqttTimer", pdMS_TO_TICKS(2000), pdFALSE, (void*)0, + reinterpret_cast(connectToMqtt)); + + mqttClient.onConnect(onMqttConnect); + mqttClient.onDisconnect(onMqttDisconnect); + mqttClient.onSubscribe(onMqttSubscribe); + mqttClient.onUnsubscribe(onMqttUnsubscribe); + mqttClient.onMessage(onMqttMessage); + mqttClient.onPublish(onMqttPublish); + + mqttClient.setServer(MQTT_HOST, MQTT_PORT); + +#if ASYNC_TCP_SSL_ENABLED + mqttClient.setSecure(MQTT_SECURE); + + if (MQTT_SECURE) + { + //mqttClient.addServerFingerprint((const uint8_t[])MQTT_SERVER_FINGERPRINT); + mqttClient.addServerFingerprint((const uint8_t *)MQTT_SERVER_FINGERPRINT); + } + +#endif + + /////////////////////////////////// + + // To be called before ETH.begin() + WiFi.onEvent(ETH_event); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + //bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ, + // int SPI_HOST, uint8_t *W6100_Mac = W6100_Default_Mac); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST ); + //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[millis() % NUMBER_OF_MAC] ); + + // Static IP, leave without this line to get IP via DHCP + //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); + //ETH.config(myIP, myGW, mySN, myDNS); + + ESP32_W6100_waitForConnect(); + + /////////////////////////////////// +} + +void loop() +{ +} diff --git a/examples/ESP32_W6100/FullyFeaturedSSL_ESP32_W6100/defines.h b/examples/ESP32_W6100/FullyFeaturedSSL_ESP32_W6100/defines.h new file mode 100644 index 0000000..cf6f2b8 --- /dev/null +++ b/examples/ESP32_W6100/FullyFeaturedSSL_ESP32_W6100/defines.h @@ -0,0 +1,76 @@ +/**************************************************************************************************************************** + defines.h + AsyncMQTT_ESP32 is a library for ESP32 boards using WiFi or LwIP W5500 / W6100 / ENC28J60 / LAN8720 Ethernet + + Based on and modified from : + + 1) async-mqtt-client (https://github.com/marvinroger/async-mqtt-client) + 2) AsyncMQTT_Generic (https://github.com/khoih-prog/AsyncMQTT_Generic) + + Built by Khoi Hoang https://github.com/khoih-prog/AsyncMQTT_ESP32 + ***************************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +// Debug Level from 0 to 4 +#define _ETHERNET_WEBSERVER_LOGLEVEL_ 1 +#define _ASYNC_MQTT_LOGLEVEL_ 1 + +////////////////////////////////////////////////////////// + +// Optional values to override default settings +// Don't change unless you know what you're doing +//#define ETH_SPI_HOST SPI3_HOST +//#define SPI_CLOCK_MHZ 25 + +// Must connect INT to GPIOxx or not working +//#define INT_GPIO 4 + +//#define MISO_GPIO 19 +//#define MOSI_GPIO 23 +//#define SCK_GPIO 18 +//#define CS_GPIO 5 + +////////////////////////////////////////////////////////// + +#include + +///////////////////////////////////////////// + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +// Select the IP address according to your local network +IPAddress myIP(192, 168, 2, 232); +IPAddress myGW(192, 168, 2, 1); +IPAddress mySN(255, 255, 255, 0); + +// Google DNS Server IP +IPAddress myDNS(8, 8, 8, 8); + +#endif //defines_h diff --git a/examples/ESP32_W6100/FullyFeatured_ESP32_W6100/FullyFeatured_ESP32_W6100.ino b/examples/ESP32_W6100/FullyFeatured_ESP32_W6100/FullyFeatured_ESP32_W6100.ino new file mode 100644 index 0000000..a6de8a0 --- /dev/null +++ b/examples/ESP32_W6100/FullyFeatured_ESP32_W6100/FullyFeatured_ESP32_W6100.ino @@ -0,0 +1,258 @@ +/**************************************************************************************************************************** + FullyFeature_ESP32_W6100.ino + + AsyncMQTT_ESP32 is a library for ESP32 boards using WiFi or LwIP W5500 / W6100 / ENC28J60 / LAN8720 Ethernet + + Based on and modified from : + + 1) async-mqtt-client (https://github.com/marvinroger/async-mqtt-client) + 2) AsyncMQTT_Generic (https://github.com/khoih-prog/AsyncMQTT_Generic) + + Built by Khoi Hoang https://github.com/khoih-prog/AsyncMQTT_ESP32 + *****************************************************************************************************************************/ +/* + This example uses FreeRTOS softwaretimers as there is no built-in Ticker library +*/ + +#include "defines.h" + +extern "C" +{ +#include "freertos/FreeRTOS.h" +#include "freertos/timers.h" +} + +#include + +//#define MQTT_HOST IPAddress(192, 168, 2, 110) +#define MQTT_HOST "broker.emqx.io" // Broker address +#define MQTT_PORT 1883 + +const char *PubTopic = "async-mqtt/ESP32_W6100_Pub"; // Topic to publish + +AsyncMqttClient mqttClient; +TimerHandle_t mqttReconnectTimer; + +void connectToMqtt() +{ + Serial.println("Connecting to MQTT..."); + mqttClient.connect(); +} + +void ETH_event(WiFiEvent_t event) +{ + switch (event) + { +#if USING_CORE_ESP32_CORE_V200_PLUS + + case ARDUINO_EVENT_ETH_START: + Serial.println("ETH starting"); + break; + + case ARDUINO_EVENT_ETH_CONNECTED: + Serial.println("ETH connected"); + break; + + case ARDUINO_EVENT_ETH_GOT_IP: + Serial.println("ETH got IP"); + Serial.print("IP address: "); + Serial.println(ETH.localIP()); + connectToMqtt(); + break; + + case ARDUINO_EVENT_ETH_DISCONNECTED: + Serial.println("ETH lost connection"); + + // ensure we don't reconnect to MQTT when no ETH + xTimerStop(mqttReconnectTimer, 0); + + break; + + case ARDUINO_EVENT_ETH_STOP: + Serial.println("ETH stops"); + + // ensure we don't reconnect to MQTT when no ETH + xTimerStop(mqttReconnectTimer, 0); + + break; +#else + + case SYSTEM_EVENT_ETH_CONNECTED: + erial.println(F("ETH Connected")); + break; + + case SYSTEM_EVENT_ETH_GOT_IP: + Serial.println("ETH connected"); + Serial.println("IP address: "); + Serial.println(ETH.localIP()); + connectToMqtt(); + break; + + case SYSTEM_EVENT_ETH_DISCONNECTED: + case SYSTEM_EVENT_ETH_STOP: + Serial.println("ETH lost connection"); + + // ensure we don't reconnect to MQTT when no ETH + xTimerStop(mqttReconnectTimer, 0); + + break; +#endif + + default: + break; + } +} + +void printSeparationLine() +{ + Serial.println("************************************************"); +} + +void onMqttConnect(bool sessionPresent) +{ + Serial.print("Connected to MQTT broker: "); + Serial.print(MQTT_HOST); + Serial.print(", port: "); + Serial.println(MQTT_PORT); + Serial.print("PubTopic: "); + Serial.println(PubTopic); + + printSeparationLine(); + Serial.print("Session present: "); + Serial.println(sessionPresent); + + uint16_t packetIdSub = mqttClient.subscribe(PubTopic, 2); + Serial.print("Subscribing at QoS 2, packetId: "); + Serial.println(packetIdSub); + + mqttClient.publish(PubTopic, 0, true, "ESP32_W6100 Test"); + Serial.println("Publishing at QoS 0"); + + uint16_t packetIdPub1 = mqttClient.publish(PubTopic, 1, true, "test 2"); + Serial.print("Publishing at QoS 1, packetId: "); + Serial.println(packetIdPub1); + + uint16_t packetIdPub2 = mqttClient.publish(PubTopic, 2, true, "test 3"); + Serial.print("Publishing at QoS 2, packetId: "); + Serial.println(packetIdPub2); + + printSeparationLine(); +} + +void onMqttDisconnect(AsyncMqttClientDisconnectReason reason) +{ + (void) reason; + + Serial.println("Disconnected from MQTT."); + + if (ESP32_W6100_isConnected()) + { + xTimerStart(mqttReconnectTimer, 0); + } +} + +void onMqttSubscribe(const uint16_t& packetId, const uint8_t& qos) +{ + Serial.println("Subscribe acknowledged."); + Serial.print(" packetId: "); + Serial.println(packetId); + Serial.print(" qos: "); + Serial.println(qos); +} + +void onMqttUnsubscribe(const uint16_t& packetId) +{ + Serial.println("Unsubscribe acknowledged."); + Serial.print(" packetId: "); + Serial.println(packetId); +} + +void onMqttMessage(char* topic, char* payload, const AsyncMqttClientMessageProperties& properties, + const size_t& len, const size_t& index, const size_t& total) +{ + (void) payload; + + Serial.println("Publish received."); + Serial.print(" topic: "); + Serial.println(topic); + Serial.print(" qos: "); + Serial.println(properties.qos); + Serial.print(" dup: "); + Serial.println(properties.dup); + Serial.print(" retain: "); + Serial.println(properties.retain); + Serial.print(" len: "); + Serial.println(len); + Serial.print(" index: "); + Serial.println(index); + Serial.print(" total: "); + Serial.println(total); +} + +void onMqttPublish(const uint16_t& packetId) +{ + Serial.println("Publish acknowledged."); + Serial.print(" packetId: "); + Serial.println(packetId); +} + +void setup() +{ + Serial.begin(115200); + + while (!Serial && millis() < 5000); + + delay(500); + + Serial.print("\nStarting FullyFeature_ESP32_W6100 on "); + Serial.print(ARDUINO_BOARD); + Serial.println(" with " + String(SHIELD_TYPE)); + Serial.println(WEBSERVER_ESP32_W6100_VERSION); + Serial.println(ASYNC_MQTT_ESP32_VERSION); + + AMQTT_LOGWARN(F("Default SPI pinout:")); + AMQTT_LOGWARN1(F("SPI_HOST:"), ETH_SPI_HOST); + AMQTT_LOGWARN1(F("MOSI:"), MOSI_GPIO); + AMQTT_LOGWARN1(F("MISO:"), MISO_GPIO); + AMQTT_LOGWARN1(F("SCK:"), SCK_GPIO); + AMQTT_LOGWARN1(F("CS:"), CS_GPIO); + AMQTT_LOGWARN1(F("INT:"), INT_GPIO); + AMQTT_LOGWARN1(F("SPI Clock (MHz):"), SPI_CLOCK_MHZ); + AMQTT_LOGWARN(F("=========================")); + + mqttReconnectTimer = xTimerCreate("mqttTimer", pdMS_TO_TICKS(2000), pdFALSE, (void*)0, + reinterpret_cast(connectToMqtt)); + + mqttClient.onConnect(onMqttConnect); + mqttClient.onDisconnect(onMqttDisconnect); + mqttClient.onSubscribe(onMqttSubscribe); + mqttClient.onUnsubscribe(onMqttUnsubscribe); + mqttClient.onMessage(onMqttMessage); + mqttClient.onPublish(onMqttPublish); + + mqttClient.setServer(MQTT_HOST, MQTT_PORT); + + /////////////////////////////////// + + // To be called before ETH.begin() + WiFi.onEvent(ETH_event); + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + //bool begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ, + // int SPI_HOST, uint8_t *W6100_Mac = W6100_Default_Mac); + ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST ); + //ETH.begin( MISO_GPIO, MOSI_GPIO, SCK_GPIO, CS_GPIO, INT_GPIO, SPI_CLOCK_MHZ, ETH_SPI_HOST, mac[millis() % NUMBER_OF_MAC] ); + + // Static IP, leave without this line to get IP via DHCP + //bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0); + //ETH.config(myIP, myGW, mySN, myDNS); + + ESP32_W6100_waitForConnect(); + + /////////////////////////////////// +} + +void loop() +{ +} diff --git a/examples/ESP32_W6100/FullyFeatured_ESP32_W6100/defines.h b/examples/ESP32_W6100/FullyFeatured_ESP32_W6100/defines.h new file mode 100644 index 0000000..cf6f2b8 --- /dev/null +++ b/examples/ESP32_W6100/FullyFeatured_ESP32_W6100/defines.h @@ -0,0 +1,76 @@ +/**************************************************************************************************************************** + defines.h + AsyncMQTT_ESP32 is a library for ESP32 boards using WiFi or LwIP W5500 / W6100 / ENC28J60 / LAN8720 Ethernet + + Based on and modified from : + + 1) async-mqtt-client (https://github.com/marvinroger/async-mqtt-client) + 2) AsyncMQTT_Generic (https://github.com/khoih-prog/AsyncMQTT_Generic) + + Built by Khoi Hoang https://github.com/khoih-prog/AsyncMQTT_ESP32 + ***************************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +// Debug Level from 0 to 4 +#define _ETHERNET_WEBSERVER_LOGLEVEL_ 1 +#define _ASYNC_MQTT_LOGLEVEL_ 1 + +////////////////////////////////////////////////////////// + +// Optional values to override default settings +// Don't change unless you know what you're doing +//#define ETH_SPI_HOST SPI3_HOST +//#define SPI_CLOCK_MHZ 25 + +// Must connect INT to GPIOxx or not working +//#define INT_GPIO 4 + +//#define MISO_GPIO 19 +//#define MOSI_GPIO 23 +//#define SCK_GPIO 18 +//#define CS_GPIO 5 + +////////////////////////////////////////////////////////// + +#include + +///////////////////////////////////////////// + +// Enter a MAC address and IP address for your controller below. +#define NUMBER_OF_MAC 20 + +byte mac[][NUMBER_OF_MAC] = +{ + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, + { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, +}; + +// Select the IP address according to your local network +IPAddress myIP(192, 168, 2, 232); +IPAddress myGW(192, 168, 2, 1); +IPAddress mySN(255, 255, 255, 0); + +// Google DNS Server IP +IPAddress myDNS(8, 8, 8, 8); + +#endif //defines_h diff --git a/library.json b/library.json index 57aabfe..0aa0602 100644 --- a/library.json +++ b/library.json @@ -1,8 +1,8 @@ { "name": "AsyncMQTT_ESP32", - "version": "1.9.0", - "keywords": "communication, iot, automation, async, async-tcp, async-tcp-ssl, async-mqtt, mqtt, async-mqtt-client, esp8266, esp32, stm32, portenta-h7, wt32-eth01, tls, teensy-41, qn-ethernet, lwip, lan8742a, lan8720", - "description": "Arduino Library for ESP32/S2/S3/C3 asynchronous MQTT client implementation. This library, ported to support ESP32/S2/S3/C3, WT32_ETH01 (ESP32 + LAN8720), ESP32 using LwIP ENC28J60, W5500 or LAN8720. Supporting TLS/SSL for MQTTS Client", + "version": "1.10.0", + "keywords": "communication, iot, automation, async, async-tcp, async-tcp-ssl, async-mqtt, mqtt, async-mqtt-client, esp32, esp32-s2, esp32-s3, esp32-c3, wt32-eth01, ethernet, w5500, w6100, enc28j60, lan8720, lwip, lwip-ethernet, lwip-enc28j60, lwip-w5500, lwip-w6100, lwip-lan8720", + "description": "Arduino Library for ESP32/S2/S3/C3 asynchronous MQTT client implementation. This library, ported to support ESP32/S2/S3/C3, WT32_ETH01 (ESP32 + LAN8720), ESP32 using LwIP ENC28J60, W5500, W6100 or LAN8720. Supporting TLS/SSL for MQTTS Client", "authors": [ { @@ -43,26 +43,38 @@ }, { "owner": "khoih-prog", - "name": "WebServer_ESP32_W5500", + "name": "WebServer_ESP32_ENC", "version": ">=1.5.1", "platforms": ["espressif32"] }, { "owner": "khoih-prog", - "name": "WebServer_ESP32_ENC", - "version": ">=1.5.1", + "name": "WebServer_ESP32_SC_ENC", + "version": ">=1.2.0", + "platforms": ["espressif32"] + }, + { + "owner": "khoih-prog", + "name": "WebServer_ESP32_W5500", + "version": ">=1.5.2", "platforms": ["espressif32"] }, { "owner": "khoih-prog", "name": "WebServer_ESP32_SC_W5500", - "version": ">=1.2.0", + "version": ">=1.2.1", "platforms": ["espressif32"] }, { "owner": "khoih-prog", - "name": "WebServer_ESP32_SC_ENC", - "version": ">=1.2.0", + "name": "WebServer_ESP32_W6100", + "version": ">=1.5.2", + "platforms": ["espressif32"] + }, + { + "owner": "khoih-prog", + "name": "WebServer_ESP32_SC_W6100", + "version": ">=1.2.1", "platforms": ["espressif32"] } ], diff --git a/library.properties b/library.properties index 187f6ee..13d7120 100644 --- a/library.properties +++ b/library.properties @@ -1,12 +1,12 @@ name=AsyncMQTT_ESP32 -version=1.9.0 +version=1.10.0 author=Marvin ROGER,Khoi Hoang maintainer=Khoi Hoang sentence=Arduino Library for ESP32/S2/S3/C3 asynchronous MQTT client implementation -paragraph=This library, ported to support ESP32/S2/S3/C3, WT32_ETH01 (ESP32 + LAN8720), ESP32 using LwIP ENC28J60, W5500 or LAN8720. Supporting TLS/SSL for MQTTS Client +paragraph=This library, ported to support ESP32/S2/S3/C3, WT32_ETH01 (ESP32 + LAN8720), ESP32 using LwIP ENC28J60, W5500, W6100 or LAN8720. Supporting TLS/SSL for MQTTS Client category=Communication url=https://github.com/khoih-prog/AsyncMQTT_ESP32 architectures=* license=MIT -depends=AsyncTCP_SSL, WebServer_WT32_ETH01, WebServer_ESP32_W5500, WebServer_ESP32_ENC, WebServer_ESP32_SC_W5500, WebServer_ESP32_SC_ENC +depends=AsyncTCP_SSL, WebServer_WT32_ETH01, WebServer_ESP32_ENC, WebServer_ESP32_W5500, WebServer_ESP32_SC_ENC, WebServer_ESP32_SC_W5500, WebServer_ESP32_W6100, WebServer_ESP32_SC_W6100 includes=AsyncMQTT_ESP32.h diff --git a/platformio/platformio.ini b/platformio/platformio.ini index 05806c5..3177f83 100644 --- a/platformio/platformio.ini +++ b/platformio/platformio.ini @@ -42,18 +42,23 @@ lib_deps = ; AsyncTCP@>=1.1.1 ; AsyncTCP_SSL@>=1.3.1 ; WebServer_WT32_ETH01@>=1.5.1 -; WebServer_ESP32_W5500@>=1.5.1 ; WebServer_ESP32_ENC@>=1.5.1 -; WebServer_ESP32_SC_W5500@>=1.2.0 ; WebServer_ESP32_SC_ENC@>=1.2.0 +; WebServer_ESP32_W5500@>=1.5.2 +; WebServer_ESP32_SC_W5500@>=1.2.1 +; WebServer_ESP32_W6100@>=1.5.2 +; WebServer_ESP32_SC_W6100@>=1.2.1 + ; PlatformIO 5.x me-no-dev/AsyncTCP@>=1.1.1 khoih-prog/AsyncTCP_SSL@>=1.3.1 khoih-prog/WebServer_WT32_ETH01@>=1.5.1 - khoih-prog/WebServer_ESP32_W5500@>=1.5.1 khoih-prog/WebServer_ESP32_ENC@>=1.5.1 - khoih-prog/WebServer_ESP32_SC_W5500@>=1.2.0 khoih-prog/WebServer_ESP32_SC_ENC@>=1.2.0 + khoih-prog/WebServer_ESP32_W5500@>=1.5.2 + khoih-prog/WebServer_ESP32_SC_W5500@>=1.2.1 + khoih-prog/WebServer_ESP32_W6100@>=1.5.2 + khoih-prog/WebServer_ESP32_SC_W6100@>=1.2.1 build_flags = ; set your debug output (default=Serial)