Coder Social home page Coder Social logo

khoih-prog / asyncmqtt_generic Goto Github PK

View Code? Open in Web Editor NEW
59.0 5.0 10.0 897 KB

Arduino Arduino Library for ESP8266, ESP32, Portenta_H7, STM32 and RP2040W asynchronous MQTT client implementation. This library, ported to support ESP32, WT32_ETH01 (ESP32 + LAN8720), ESP8266, Portenta_H7 (Ethernet or WiFi) and STM32 (LAN8742A or LAN8720 Ethernet), Teensy 4.1 using QNEthernet, RASPBERRY_PI_PICO_W with CYW43439 WiFi. Currently supporting TLS/SSL for ESP32 only

License: MIT License

C 65.93% C++ 32.91% Shell 1.01% Python 0.15%
tls fingerprint async esp32 esp8266 stm32f7 portenta-h7 lan8720 lan8742a wt32-eth01

asyncmqtt_generic's Issues

Stuck on this error

platform.ini file as below

[common]
# ------------------------------------------------------------------------------
# PLATFORM:
#   !! DO NOT confuse platformio's ESP8266 development platform with Arduino core for ESP8266
#   platformIO 1.5.0 = arduino core 2.3.0
#   platformIO 1.6.0 = arduino core 2.4.0
#   platformIO 1.7.3 = arduino core 2.4.1
#   platformIO 1.8.0 = arduino core 2.4.2
# ------------------------------------------------------------------------------
esp8266_platform_2_3_0 = [email protected]
esp8266_platform_2_4_0 = [email protected]
esp8266_platform_2_4_1 = [email protected]
esp8266_platform_2_4_2 = [email protected]

[env]
framework = arduino
upload_speed = 460800
monitor_speed = 38400


[env:esp8266_make]
platform = ${common.esp8266_platform_2_4_0}
# platform = ${common.esp8266_platform_2_4_1}
board = esp01_1m
#board = esp01
#board = esp12e
#board = esp01
#board_build.f_cpu = 80000000L

#for BTX type ic Z logo ic
board_build.flash_mode = dout 
build_flags = 
    -g 
    #-D DEBUG_FAUXMO=Serial 
    #-D  DEBUG_FAUXMO_VERBOSE_TCP=0 
    #-D  DEBUG_FAUXMO_VERBOSE_UDP=0 
    -D PIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
    #-D  PIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
    #-D PUYA_SUPPORT=1
    #-D XMC_SUPPORT=1
lib_deps =   
     vintlabs/FauxmoESP @ 3.4
     bblanchon/ArduinoJson @ 6.12
     knolleary/PubSubClient @ 2.8
     me-no-dev/ESP Async WebServer @ 1.2.2
     me-no-dev/ESPAsyncTCP @ 1.2.2
     me-no-dev/AsyncTCP @ 1.1.1
     khoih-prog/AsyncMQTT_Generic @ 1.8.0

lib_ignore =
   STM32Ethernet
   STM32duino LwIP
    WiFi
   Teensy41_AsyncTCP
   ESPAsync_WiFiManager
   WebServer_WT32_ETH01
   STM32AsyncTCP
   AsyncTCP_SSL
   AsyncTCP_RP2040W
   Portenta_H7_AsyncTCP
   WebServer_ESP32_W5500
   WebServer_ESP32_ENC

In file included from lib/async-mqtt-client-develop/src/AsyncMqttClient.hpp:29:0,
from lib/async-mqtt-client-develop/src/AsyncMqttClient.cpp:1:

lib/async-mqtt-client-develop/src/AsyncMqttClient.cpp: In member function 'uint16_t AsyncMqttClient::publish(const char*, uint8_t, bool, const char*, size_t, bool, uint16_t)':
lib/async-mqtt-client-develop/src/AsyncMqttClient/Helpers.hpp:47:33: error: 'class EspClass' has no member named 'getMaxFreeBlockSize'
   #define GET_FREE_MEMORY() ESP.getMaxFreeBlockSize()
                                 ^
lib/async-mqtt-client-develop/src/AsyncMqttClient.cpp:739:30: note: in expansion of macro 'GET_FREE_MEMORY'
   if (_state != CONNECTED || GET_FREE_MEMORY() < MQTT_MIN_FREE_MEMORY) return 0;
                              ^
Compiling .pio/build/esp8266_make/lib500/async-mqtt-client-develop/AsyncMqttClient/Packets/Out/Connect.cpp.o
*** [.pio/build/esp8266_make/lib500/async-mqtt-client-develop/AsyncMqttClient.cpp.o] Error 1

SSL for ESP8266

Hello! with async mqtt client library, I can use SSL connection with ESP8266 using a ported version of ESPAsyncTCP is not possible with your release? It can be very usefull with 3.0.2 ESP8266 core

Documentation

Sorry, found no other way.

Where are the parameters explained in your documentation?
e.g. mqttClient.publish(PubTopic, 0, true, "ESP32 Test");

Missing default case in switch causes

Describe the bug

In the example file "FullyFeatured_ESP32.ino", the Switch case does not have a "default" to catch anything not handled.

Steps to Reproduce

Compile example "FullyFeatured_ESP32.ino" in Arduino IDE with board set to "Adafruit Feather ESP32-S2".

Expected behavior

Expected the file to compile without errors

Actual behavior

Error compiling....

Solution

Just add a default case for the WiFiEvent(WiFiEvent_t event) method outside the "if" so that both versions has a default so you don't hqve to handle all possible cases:

default: break;

Information

Arduino IDE version: 1.8.19
ESP32 Core Version 2.0.4
OS: OSX 11.6

Context:
Trying to make the basic example compile

Additional context

Relevant error message:

/Users/jensa/Documents/Arduino/FullyFeatured_ESP32/FullyFeatured_ESP32.ino: In function 'void WiFiEvent(arduino_event_id_t)':
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_SCAN_DONE' not handled in switch [-Werror=switch]
   switch (event)
          ^
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_STA_STOP' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_AP_START' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_AP_STOP' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_AP_STACONNECTED' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_AP_STADISCONNECTED' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_AP_GOT_IP6' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WIFI_FTM_REPORT' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_ETH_START' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_ETH_STOP' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_ETH_CONNECTED' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_ETH_DISCONNECTED' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_ETH_GOT_IP' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_ETH_GOT_IP6' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WPS_ER_SUCCESS' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WPS_ER_FAILED' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WPS_ER_TIMEOUT' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WPS_ER_PIN' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_WPS_ER_PBC_OVERLAP' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_SC_SCAN_DONE' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_SC_FOUND_CHANNEL' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_SC_GOT_SSID_PSWD' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_SC_SEND_ACK_DONE' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_PROV_INIT' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_PROV_DEINIT' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_PROV_START' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_PROV_END' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_PROV_CRED_RECV' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_PROV_CRED_FAIL' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_PROV_CRED_SUCCESS' not handled in switch [-Werror=switch]
FullyFeatured_ESP32:51:10: error: enumeration value 'ARDUINO_EVENT_MAX' not handled in switch [-Werror=switch]
cc1plus: some warnings being treated as errors
Multiple libraries were found for "WiFi.h"
 Used: /Users/jensa/Library/Arduino15/packages/esp32/hardware/esp32/2.0.4/libraries/WiFi
 Not used: /Applications/Arduino.app/Contents/Java/libraries/WiFi
Using library WiFi at version 2.0.0 in folder: /Users/jensa/Library/Arduino15/packages/esp32/hardware/esp32/2.0.4/libraries/WiFi 
Using library AsyncMQTT_Generic at version 1.6.1 in folder: /Users/jensa/Documents/Arduino/libraries/AsyncMQTT_Generic 
Using library AsyncTCP at version 1.1.1 in folder: /Users/jensa/Documents/Arduino/libraries/AsyncTCP 
exit status 1
enumeration value 'ARDUINO_EVENT_WIFI_SCAN_DONE' not handled in switch [-Werror=switch]

Dependencies fail to load in PlatformIO

Describe the bug

When building a project for Portenta in PlatformIO depending on AsyncMQTT_Generic, multiple errors are thrown, all seems to be related to missing stm32_def.h file. Possibly because the khoih-prog/Portenta_H7_AsyncTCP dependency fails to install.

Steps to Reproduce

  • Create new project fro Portenta H7 in platform IO
  • Add AsynqMQTT_Generic to the project using project manager.
  • Build.

Expected behavior

The blank program should build without issues

Actual behavior

Fails to build.
Dependcy khoih-prog/Portenta_H7_AsyncTCP fails to install
Multiple errors related to missing stm32_def.h file

When using the included platformio.ini file, the build crashes with the following info/error:
Library Manager: Installing stm32duino/STM32duino STM32Ethernet @ >=1.2.0 Error: Could not find the package with 'stm32duino/STM32duino STM32Ethernet @ >=1.2.0' requirements for your system 'windows_amd64'

Also, possibly unrelated, Vscode displays the following error during installation of the libraray:
Error: Multiple requests to rebuild the project "<name>" index have been received! Automatic index rebuilding process has been terminated for 10 minutes.

Information

  • Platform IO version: Core 6.0.1·Home 3.4.1
  • Vscode version: 1.67.2
  • Windows 10 Business

Additional context

It looks like the repository path for the Portenta_H7_AsyncTCP libraray is messed up on the platform.io site: (https://registry.platformio.org/libraries/khoih-prog/Portenta_H7_AsyncTCP)

image

ESP8266 SSL example

Is your feature request related to a problem? Please describe.
Please provide support for SSL support also for ESP8266

I can´t install library in platformio. Error to get ESPAsyncTCP

Hi,

when I install librery in platformio appear this error:

Library Manager: Installing git+https://github.com/khoih-prog/ESPAsyncTCP
git version 2.34.0.windows.1
Cloning into 'C:\Users\msanc.platformio.cache\tmp\pkg-installing-qo24k_s0'...
fatal: invalid branch name: init.defaultBranch =
Error: VCS: Could not process command ['git', 'clone', '--recursive', '--depth', '1', 'https://github.com/khoih-prog/ESPAsyncTCP', 'C:\Users\msanc\.platformio\.cache\tmp\pkg-installing-qo24k_s0']

This appear to be that deafultBranch is inexsitent in ESPAsyncTCP proyect

Platform.io version 6.1.5

  • ESP32 v2.0.5
  • OS WIndows 11

Regards

ESP32 PlatformIO Compilation Failure LwIP.h: No such file or directory

Describe the bug

Trying to compile AsyncMqtt_Generic library on ESP32 using PlatformIO.

Steps to Reproduce

Used FullyFeaturedSSL_ESP32.ino and tried compiling the same.

Expected behavior

Successful compile of the sketch.

Actual behavior

Getting error during compiliation.

Debug and AT-command log (if applicable)

` * Executing task in folder ESP32 Testings: C:\Users\lenovo.platformio\penv\Scripts\platformio.exe run

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Library Manager: Installing khoih-prog/AsyncMQTT_Generic @ ^1.6.1
Unpacking [####################################] 100%
Library Manager: [email protected] has been installed!
Library Manager: Resolving dependencies...
Library Manager: Installing me-no-dev/AsyncTCP @ >=1.1.1
Unpacking [####################################] 100%
Library Manager: [email protected] has been installed!
Library Manager: Installing git+https://github.com/khoih-prog/ESPAsyncTCP
git version 2.37.1.windows.1
Cloning into 'C:\Users\lenovo.platformio.cache\tmp\pkg-installing-30z7lx_o'...
remote: Enumerating objects: 51, done.
remote: Counting objects: 100% (51/51), done.
remote: Compressing objects: 100% (46/46), done.
Receiving objects: 100% (51/51)sed 23 (delta 1), pack-reused 0
Receiving objects: 100% (51/51), 51.97 KiB | 403.00 KiB/s, done.
Resolving deltas: 100% (2/2), done.
Library Manager: [email protected]+sha.7cbee24 has been installed!
Library Manager: Installing khoih-prog/AsyncTCP_SSL @ >=1.3.0
Unpacking [####################################] 100%
Library Manager: [email protected] has been installed!
Library Manager: Installing khoih-prog/ESPAsync_WiFiManager @ >=1.14.0
Unpacking [####################################] 100%
Library Manager: [email protected] has been installed!
Library Manager: Resolving dependencies...
Library Manager: Installing me-no-dev/ESP Async WebServer @ >=1.2.3
Unpacking [####################################] 100%
Library Manager: ESP Async [email protected] has been installed!
Library Manager: Resolving dependencies...
Library Manager: Installing khoih-prog/ESP_DoubleResetDetector @ >=1.3.2
Unpacking [####################################] 100%
Library Manager: [email protected] has been installed!
Library Manager: Installing khoih-prog/WebServer_WT32_ETH01 @ >=1.5.1
Unpacking [####################################] 100%
Library Manager: [email protected] has been installed!
Library Manager: Installing git+https://github.com/khoih-prog/STM32AsyncTCP
git version 2.37.1.windows.1
Cloning into 'C:\Users\lenovo.platformio.cache\tmp\pkg-installing-rapgaval'...
remote: Enumerating objects: 61, done.
remote: Counting objects: 100% (61/61), done.
remote: Compressing objects: 100% (43/43), done.
remote: Total 61 (delta 9), reused 53 (delta 9), pack-reused 0
Receiving objects: 100% (61/61), 52.72 KiB | 228.00 KiB/s, done.
Resolving deltas: 100% (9/9), done.
Library Manager: [email protected]+sha.e88a8bc has been installed!
Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (5.1.1) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:

  • framework-arduinoespressif32 @ 3.20004.220825 (2.0.4)
  • tool-esptoolpy @ 1.30300.0 (3.3.0)
  • toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3
    LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 40 compatible libraries
    Scanning dependencies...
    Dependency Graph
    |-- AsyncMQTT_Generic @ 1.7.0
    | |-- AsyncTCP @ 1.1.1
    | |-- AsyncTCP_SSL @ 1.3.1
    | | |-- WiFiClientSecure @ 2.0.0
    | | | |-- WiFi @ 2.0.0
    | | | | |-- STM32AsyncTCP @ 1.0.1+sha.e88a8bc
    | |-- ESPAsync_WiFiManager @ 1.14.1
    | | |-- AsyncTCP @ 1.1.1
    | | |-- ESP Async WebServer @ 1.2.3
    | | | |-- AsyncTCP @ 1.1.1
    | | | |-- STM32AsyncTCP @ 1.0.1+sha.e88a8bc
    | | | |-- WiFi @ 2.0.0
    | | | | |-- STM32AsyncTCP @ 1.0.1+sha.e88a8bc
    | | |-- ESP_DoubleResetDetector @ 1.3.2
    | |-- WebServer_WT32_ETH01 @ 1.5.1
    | |-- STM32AsyncTCP @ 1.0.1+sha.e88a8bc
    |-- WiFi @ 2.0.0
    | |-- STM32AsyncTCP @ 1.0.1+sha.e88a8bc
    Building in debug mode
    Compiling .pio\build\esp32dev\src\main.cpp.o
    Updating bootloader headers
    Generating partitions .pio\build\esp32dev\partitions.bin
    esptool.py v3.3
    Flash params set to 0x0220
    Wrote 0x4400 bytes to file .pio\build\esp32dev\patched_bootloader.bin, ready to flash to offset 0x1000
    Compiling .pio\build\esp32dev\libff3\AsyncTCP\AsyncTCP.cpp.o
    Compiling .pio\build\esp32dev\lib154\STM32AsyncTCP\AsyncPrinter.cpp.o
    Compiling .pio\build\esp32dev\lib154\STM32AsyncTCP\STM32AsyncTCP.cpp.o
    In file included from .pio/libdeps/esp32dev/AsyncMQTT_Generic/src/AsyncMqtt_Generic.h:34,
    from src/main.cpp:33:
    .pio/libdeps/esp32dev/AsyncMQTT_Generic/src/AsyncMqttClient_Generic.hpp:79:6: warning: #warning ESP32 ASYNC_TCP_SSL_ENABLED [-Wcpp]
    #warning ESP32 ASYNC_TCP_SSL_ENABLED
    ^~~~~~~
    In file included from .pio/libdeps/esp32dev/STM32AsyncTCP/src/AsyncPrinter.h:26,
    from .pio/libdeps/esp32dev/STM32AsyncTCP/src/AsyncPrinter.cpp:22:
    .pio/libdeps/esp32dev/STM32AsyncTCP/src/STM32AsyncTCP.h:29:10: fatal error: LwIP.h: No such file or directory


#include <LwIP.h>
^~~~~~~~
compilation terminated.
*** [.pio\build\esp32dev\lib154\STM32AsyncTCP\AsyncPrinter.cpp.o] Error 1
In file included from .pio/libdeps/esp32dev/STM32AsyncTCP/src/STM32AsyncTCP.cpp:75:
.pio/libdeps/esp32dev/STM32AsyncTCP/src/STM32AsyncTCP.h:29:10: fatal error: LwIP.h: No such file or directory



#include <LwIP.h>
^~~~~~~~
compilation terminated.
*** [.pio\build\esp32dev\lib154\STM32AsyncTCP\STM32AsyncTCP.cpp.o] Error 1
======================================================================================= [FAILED] Took 64.87 seconds =======================================================================================`

Information

Please ensure to specify the following:

  • Platform IO 6.1.4
  • ESP32 2.0.4
  • Compile FullyFeaturedSSL_ESP32 sketch
  • Add these entries to platformio.ini and compile the sketch
    monitor_speed = 115200 monitor_filters = esp32_exception_decoder ; For Debugging crashes build_type = debug ; For Debugging crashes board_build.filesystem = littlefs lib_deps = khoih-prog/AsyncMQTT_Generic @ ^1.6.1
  • Running on Windows 10

[OBSERVED] disconnection after router reboot ESP8266 : with 512 ESP MIN MEMORY paramter

Describe the bug

A clear and concise description of what the bug is.
my observation:
following configuration with 512 helps mqtt to get re-connect again when router is restarted and net gets online, but when i put 4096 , it dont reconnect automatically
in file : AsyncMqttClient_Generic.hpp
#ifndef MQTT_MIN_FREE_MEMORY
// #define MQTT_MIN_FREE_MEMORY 4096
#define MQTT_MIN_FREE_MEMORY 512
#endif

Steps to Reproduce

to reproduce the error
following is the hardware

Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz

Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...

Expected behavior

expected behaviour should be it should autoconnect with 4096 value [ i may be not aware of that #define parameter, please enlighten is i am being blind to any obvious thing, thanks ]

Actual behavior

behaviour should be autoconected after router it rebooted , you can check this scene by running library on esp8266 as above and then reboot router from web ui control panel, and observe the disconnection in serial logs

Debug and AT-command log (if applicable)

[ logs when 512 size connect logs ]

12:58:55:641] Connecting to MQTT...␍␊
[12:58:55:666] <removed ip address here intentionally>␍␊
[12:58:55:823] Connected to MQTT broker: [MAIN] Free heap: 38248 bytes␊
[12:59:02:691] [MAIN] Free heap: 38656 bytes␊
[12:59:07:692] [MAIN] Free heap: 38656 bytes␊

[ log when 4096]
first it connected automtically but when in restart it it show freq disconnection

[13:11:04:773] Connecting to MQTT...␍␊
[13:11:04:797] <broker hidden>
[13:11:04:825] Connected to MQTT broker: [MAIN] Free heap: 40656 bytes␊
[13:11:14:435] [MAIN] Free heap: 40656 bytes␊
[13:11:19:437] [MAIN] Free heap: 40656 bytes␊
[13:11:24:437] [MAIN] Free heap: 40656 bytes␊
[13:11:29:439] [MAIN] Free heap: 37456 bytes␊
[13:11:34:440] [MAIN] Free heap: 37456 bytes␊
[13:11:38:925] Disconnected from MQTT.␍␊
[13:11:39:441] [MAIN] Free heap: 41816 bytes␊
[13:11:44:442] [MAIN] Free heap: 40144 bytes␊
[13:11:49:590] [MAIN] Free heap: 40144 bytes␊
[13:11:52:490] 192.168.0.102␍␊
[13:11:52:507] Connecting to MQTT...␍␊
[13:11:52:531] <broker hidden>
[13:11:54:591] [MAIN] Free heap: 37224 bytes␊
[13:11:59:515] Disconnected from MQTT.␍␊
[13:11:59:592] [MAIN] Free heap: 38448 bytes␊
[13:12:01:515] Connecting to MQTT...␍␊
[13:12:01:541] <broker hidden>
[13:12:04:593] [MAIN] Free heap: 38448 bytes␊
[13:12:08:515] Disconnected from MQTT.␍␊
[13:12:09:594] [MAIN] Free heap: 38448 bytes␊
[13:12:10:515] Connecting to MQTT...␍␊
[13:12:10:546] <broker hidden>
[13:12:14:596] [MAIN] Free heap: 38448 bytes␊

Screenshots

NA

Information

Please ensure to specify the following:

my included libraries:

#include <ESP8266WiFi.h>
#include <Ticker.h>
#include <AsyncMqtt_Generic.h>
#include <Hash.h>

#include <ESP8266WiFiMulti.h>
#include <ESPAsyncWebServer.h>
#include "fauxmoESP.h"
#include <DNSServer.h>
#include <PubSubClient.h>
#include <FS.h>
#include <ArduinoJson.h>

platform ini file as below

#platform = ${common.esp8266_platform_2_4_0}
platform = ${common.esp8266_platform_2_7_0}
# platform = ${common.esp8266_platform_2_4_1}
board = esp01_1m
#board = esp01
#board = esp12e
#board = esp01
#board_build.f_cpu = 80000000L

#for BTX type ic Z logo ic
board_build.flash_mode = dout 
build_flags = 
    -g 
    #-D DEBUG_FAUXMO=Serial 
    #-D  DEBUG_FAUXMO_VERBOSE_TCP=0 
    #-D  DEBUG_FAUXMO_VERBOSE_UDP=0 
    -D PIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
    #-D  PIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
    #-D PUYA_SUPPORT=1
    #-D XMC_SUPPORT=1
lib_deps =   
    vintlabs/FauxmoESP @ 3.4
    bblanchon/ArduinoJson @ 6.12
    knolleary/PubSubClient @ 2.8
    me-no-dev/ESP Async WebServer @ 1.2.2
    ; me-no-dev/ESPAsyncTCP @ 1.2.2
    me-no-dev/AsyncTCP @ 1.1.1
    khoih-prog/AsyncMQTT_Generic @ 1.8.0

code snippets from my code

void onMqttConnect(bool sessionPresent)
{
	String node = "client" + String(ESP.getChipId());
	String nodeid = node + " " + WiFi.localIP().toString();

	node = String(ESP.getChipId());

	String topicx = getParameterFromJson("topicname", "/config.json");
	String nodex = "{\"node\":\"" + node + "\",\"topic\":\"" + topicx + "\",\"client\":\"" + nodeid + "\"}";
	mqttClient.publish("modelStatus", 0, false, nodex.c_str());

	mqttClient.subscribe(topicx.c_str(), 2);

	Serial.print("Connected to MQTT broker: ");
}


void connectToMqtt()
{
	Serial.println("Connecting to MQTT...");
	// mqttClient.disconnect();
	mqttClient.connect();
}

void onMqttDisconnect(AsyncMqttClientDisconnectReason reason)
{
	(void)reason;

	Serial.println("Disconnected from MQTT.");

	if (WiFi.isConnected())
	{
		mqttReconnectTimer.once(2, connectToMqtt);
	}
}

//in setup>>

wifiConnectHandler = WiFi.onStationModeGotIP(onWifiConnect);
wifiDisconnectHandler = WiFi.onStationModeDisconnected(onWifiDisconnect);

mqttClient.onConnect(onMqttConnect);
mqttClient.onDisconnect(onMqttDisconnect);
mqttClient.onSubscribe(onMqttSubscribe);
mqttClient.onUnsubscribe(onMqttUnsubscribe);
mqttClient.onMessage(onMqttMessage);
mqttClient.onPublish(onMqttPublish);
// mqttClient.setServer(MQTT_HOST, MQTT_PORT);
// String broker = getParameterFromJson("broker","/config.json");
// uint16_t port = 1883;
// Serial.println(broker);
mqttClient.setServer("brokerdomain_name", 1883);
// mqttClient.setServer("192.168.0.110", 1883);

connectToWifi();

Why include implementation in header?

Describe the bug

The reason for we can only include AsyncMqtt_Generic.h in one .cpp or .ino is because it contains not only headers but also implementations. In particular, AsyncMqtt_Generic.h:

#include "AsyncMqttClient_Generic.hpp"
#include "AsyncMqttClient_Generic_Impl.h"

Which AsyncMqttClient_Generic_Impl.h is actually implementation instead of header. In common practice, the AsyncMqttClient_Generic_Impl.h should end with .cpp/.c instead of .h. And use compiler configuration/compile script to let compiler compile it as object(and later linking) explicitly.
I'm curious why you take this approach to put header and implementation together. Is that something I missed?

And here's a problem: this approach makes abstracting/inheriting or even simply include in multiple files within same project impossible without modifying your code. For example:

  1. include AsyncMqtt_Generic.h in two cpp(ino is actually cpp) of same project will result double definition.
  2. include only AsyncMqttClient_Generic.hpp will result implementation not found, even if I use some trick to let compiler compile the AsyncMqttClient_Generic_Impl.h. I can do this in AsyncMqttClient_Generic_Impl.h for latter to make things work:
#include "AsyncMqttClient_Generic.hpp"

But then I have to modify your code. It's not "generic" anymore. So may I ask why would you take this approach?

SSL Connection to a MQTT broker triggers watchdog - WT32_ETH01 board

Hi,
I am not sure if its a bug or any mistake by me but thought this post will be usefull at the end.

Using:
WT32_ETH01 board
Arduino 1.8.19
AsyncMQTT_Generic v.1.4.0

Trying to connect to MQTT broker, myqtthub.com with SSL, using the /examples/WT32_ETH01/.
Only changed these from the original example code:

#define MQTT_HOST "node02.myqtthub.com"

const uint8_t MQTT_SERVER_FINGERPRINT[] = {0x97, 0xE2, 0x30, 0xF9, 0xAE, 0x79, 0x16, 0xED, 0xDB, 0x2F, 0x9B, 0x78, 0xE5, 0xF2, 0x6D, 0x2C, 0x07, 0x6E, 0xCD, 0x2F};

Get the fingerprint of the server from this adress: (got from the last certificate page, at top, not sure if it is ok)

https://crt.sh/?q=node02.myqtthub.com

When run the debug shows:

Starting FullyFeatureSSL_WT32_ETH01 on WT32-ETH01 with ETH_PHY_LAN8720
WebServer_WT32_ETH01 v1.4.0 for core v1.0.6-
AsyncMQTT_Generic v1.4.0 for ESP32 core v1.0.6-
ETH Connected
ETH connected
IP address: 
192.168.1.145
Connecting to MQTT...
E (18585) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (18585) task_wdt:  - async_tcp_ssl (CPU 0/1)
E (18585) task_wdt: Tasks currently running:
E (18585) task_wdt: CPU 0: IDLE0
E (18585) task_wdt: CPU 1: IDLE1
E (18585) task_wdt: Aborting.
abort() was called at PC 0x401505b0 on core 0

ELF file SHA256: 0000000000000000

Backtrace: 0x40088708:0x3ffbf880 0x40088985:0x3ffbf8a0 0x401505b0:0x3ffbf8c0 0x40086f1d:0x3ffbf8e0 0x401654d3:0x3ffbc260 0x4015201f:0x3ffbc280 0x4008b145:0x3ffbc2a0 0x40089996:0x3ffbc2c0

Rebooting...
ets Jun  8 2016 00:22:57

When tried without a secure(SSL) connection it is working.
Even if the fingerprint code is wrong, it should show that it can not connect, instead when trying to connect watchdog triggers.

I could not find any other info to publish here.
If doing something wrong, any info will be usefull, thank you.

MQTT + SSL Compilation Error "include/ssl.h" No such file or directory.

Describe the bug

Compile fails when ASYNC_TCP_SSL_ENABLED is set.

Steps to Reproduce

#define ASYNC_TCP_SSL_ENABLED true

in setup()
#if ASYNC_TCP_SSL_ENABLED mqttClient.setSecure(MQTT_SECURE); #endif

and compile in Arduino IDE.

Expected behavior

Compile without error and MQTT over SSL should work.

Actual behavior

Compilation fails with error
C:\Users\lenovo\Documents\Arduino\libraries\ESPAsyncTCP-master\src/tcp_axtls.h:44:10: fatal error: include/ssl.h: No such file or directory 44 | #include "include/ssl.h" | ^~~~~~~~~~~~~~~ compilation terminated.

Information

Please ensure to specify the following:

  • Arduino IDE version (e.g. 1.8.18) or Platform.io version
  • ESP8266 Core Version (e.g. ESP8266 core v3.0.2)
  • Trying to enable MQTT + SSL.
  • Simplest possible steps to reproduce
  • Anything that might be relevant in your opinion, such as:
    • Operating system (Windows)
    • Network configuration

Combining Async_MQTT Generic and Portenta_H7_AsyncWebServer fails

Hi, back after some tests.

Combined 2 examples, exactly one-on-one: Portenta_H7_AsyncWebServer plus AsyncMQTT_Generic
Same issue as with the PubSubClinet library: Mbed OS crashes after webserver html calls within 1-2 minutes.
Problem : Both Async libraries can not co-exists.

Can' t post the issue at the Portenta_H7_AsyncWebServer git as its archived after our last mail exchange.

Jay

Arduino IDE 1.8.18
Arduino IDE 2.0
Portenta H7 rev2
lib Portenta_H7_AsyncWebServer 1.4.2
lib Portenta_H7_AsyncTCP 1.4.0
lib AsyncMQTT_Generic 1.8.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.