Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MQTT username/password support #1

Closed
wants to merge 1 commit into from

Conversation

janchrillesen
Copy link

Please add MQTT authentification support

@janchrillesen
Copy link
Author

Ignore this - sorry

ghost pushed a commit that referenced this pull request Oct 4, 2016
TD-er pushed a commit that referenced this pull request Mar 1, 2018
TD-er pushed a commit that referenced this pull request Apr 11, 2018
TD-er pushed a commit that referenced this pull request Apr 13, 2018
TD-er pushed a commit that referenced this pull request Apr 13, 2018
* Initial re-organisation of plugin sets (#1019)

* 12bit ADC values acceted up to 4095

MCP3221 is a 12bit ADC so accepted values should be up to 40195 not 1024

* automaticly updated release notes for v2.0-20180313

* - move all structs from ESPEasy.ino into header file
- add some fix for headers
- add const to rtttl notes array

* [issue #1066] Fix Webserver handle_control

There wasn't a proper start/end for the streaming webserver.
See discussion on issue #1066

* automaticly updated release notes for mega-20180314

* Custom controller GUI option

* Fixed #433

Not tested!

* #893, part 2 receiving

* Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega

# Conflicts:
#	src/ESPEasy.ino

* Rules fix

* #893 part1, send messages

* Custom controller GUI option

* #893, part 2 receiving

* Rules fix

* automaticly updated release notes for mega-20180315

* - move all structs from ESPEasy.ino into header file

- add some fix for headers
- add const to rtttl notes array

* Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega

# Conflicts:
#	src/ESPEasy.ino

* [v2.0 split globals] Base split on v2.0 version of ESPEasy.ino

*  MCP3221 allow values for calibration (#1073)

MCP3221 allow values for calibration

* [issue #1066] Fix Webserver handle_control (#1079)

[issue #1066] Fix Webserver handle_control

* Fixed multi instance problem on SHT3x #433 (#1081)

Fixed multi instance problem on SHT3x #433

* [issue #1057] AM PM display issue

X:XX PM (for hours 1...9)
X:XX AM (for hours 1...9)
XX:XX PM (for hours 10...12)
XX:XX AM (for hours 10...12)

Added for H:MM (without seconds) notations:
- `%systm_hm%`
-`%systm_hm_am%`

* [issue #993] variable in MQTT subscribe topic

As [noted](#993 (comment)) by @kluszcyn

* [issue #951] Changed System#Initialized  => System#Wake

Changed System#Initialized  => System#Wake
New event name makes more sense and Initialized may be used later to indicate all needed connections, etc. are ready.

* [issue #1057] AM PM display issue

X:XX PM (for hours 1...9)
X:XX AM (for hours 1...9)
XX:XX PM (for hours 10...12)
XX:XX AM (for hours 10...12)

Added for H:MM (without seconds) notations:
- `%systm_hm%`
-`%systm_hm_am%`

* [issue #993] variable in MQTT subscribe topic

As [noted](#993 (comment)) by @kluszcyn

* [issue #951] Changed System#Initialized  => System#Wake

Changed System#Initialized  => System#Wake
New event name makes more sense and Initialized may be used later to indicate all needed connections, etc. are ready.

* automaticly updated release notes for mega-20180316

* automaticly updated release notes for v2.0-20180316

* Add download button for current rule set

* - add encoder write #1086

* changed memory tracker to uint64_t for the ESP32

* Changed so that running all tasks immediately with deep sleep enabled only happens on first iteration after wake up

* Keep uint. Just change the init value.

* [WiFi] Try to minimize effect of WiFi interruptions

And send event when connected to a different accesspoint.
Currently the impact on WiFi reconnects is enorm. The ESP stalls, won't react on events, etc.

* - fix success setting

* - fix P073 success setting in PLUGIN_WRITE callback

* - initialize pointer in P073

* [Relaxed WiFi] Perform WiFi initialization in steps

Doing WiFi initialization in multiple steps, will reduce boot time a lot.
For deepsleep the Setup is waiting for wifi initialization to complete, but for normal use the wifi connection is initiated during setup and checked on regular intervals to see if it is available.
The same for WiFi reconnect, which will hopefully not affect the performance of the ESP module during reconnects.

Also added a check + event when connected to another accesspoint with different BSSID (MAC address of accesspoint). Also the last used BSSID is used to reconnect to try to connect to the same device over and over, which may be useful with WiFi repeaters.

* [Travis error] Some #include test that wasn't meant to be included

... in the commit.

* [JSON] Add uint name (#1099) and WiFi information (PR #1113)

As suggested by @Grovkillen on PR #1113.

* [issue #1007] Allow user specific data in separate file

File will be ignored by git and can be simply included using `-D USE_OWN_DEFAULTS` in the build

* #ifndef instead of #ifdef

* [issue #1007] Add other defines as suggested by @uzi18

* [Memory] parseTemplate did not check if markers were found

"Free Mem" reported this function to be using quite a lot of memory.
Maybe that was related to parsing texts without matching ']' or '#'
Just added some checks to see if they were found.

* [issue #1097] MQTT publish after deep sleep

The MQTTConnect was only called after a while. This is a problem for deepsleep.
So now the MQTT connect is done at the first loop when deep sleep is enabled.

* Add download button for current rule set (#1102)

Add download button for current rule set

* - add encoder write command #1086 (#1103)

- add encoder write command #1086

* Changed so that running all tasks immediately with deep sleep enabled… (#1110)

Changed so that running all tasks immediately with deep sleep enabled only happens on first iteration after wake up

* Merge pull request #1112 from uzi18/fix-p073

Fix p073 - #1111

* Merge pull request #1114 from TD-er/feature/wifi_details_json

[JSON] Add uint name (#1099) and WiFi information (PR #1113)

* Merge pull request #1113 from TD-er/feature/reduce_impact_wifi_disconnect

[Relaxed WiFi] Perform WiFi initialization in steps

* Merge pull request #1116 from TD-er/feature/allow_own_defaults

[issue #1007] Allow user specific data in separate file

* Merge pull request #1118 from TD-er/bugfix/mqtt_publish_after_deep_sleep

[issue #1097] MQTT publish after deep sleep

* [merge] MIssing #endif due to merging.

* automaticly updated release notes for mega-20180319

* automaticly updated release notes for v2.0-20180319

* Fix wiring description for SN75176 transceiver

* Revert "Merge pull request #1116 from TD-er/feature/allow_own_defaults"

This reverts commit 8ccbdca.

* Fix wiring description for SN75176 transceiver

* Revert "Merge pull request #1116 from TD-er/feature/allow_own_defaults"

This reverts commit 8ccbdca.

* [issue #1097] WiFi connect with deepsleep enabled trigger watchdog reset

Did not allow for enough time to do background tasks while waiting for wifi connect with DeepSleep enabled.

* [issue #1097] WiFi connect with deepsleep enabled trigger watchdog reset

Did not allow for enough time to do background tasks while waiting for wifi connect with DeepSleep enabled.

* automaticly updated release notes for mega-20180320

* automaticly updated release notes for v2.0-20180320

* [wifi] Setup with factory settings could not complete

* [wifi] Setup with factory settings could not complete

* [merge issue] Forgotten #endif in merge

* - P012 fix command interpretation

* - P023 fix command interpretation

* - P035 move strings to flash

* - P048 fetch params only when needed

* automaticly updated release notes for mega-20180321

* automaticly updated release notes for v2.0-20180321

* Serial WD crash

* [wifi] Make more robust checks and increase timeout

See #1145

* - P012 fix command interpretation

* - P023 fix command interpretation

* - P035 move strings to flash

* - P048 fetch params only when needed

* Serial WD crash

* [wifi] Make more robust checks and increase timeout

See #1145

* [Memory] parseTemplate did not check if markers were found

"Free Mem" reported this function to be using quite a lot of memory.
Maybe that was related to parsing texts without matching ']' or '#'
Just added some checks to see if they were found.

* [WiFi] Take much more time for initial WiFi connect during setup

Accesspoint is still active, so it may take a lot more time to make the initial connection

* [WiFi] Take much more time for initial WiFi connect during setup

Accesspoint is still active, so it may take a lot more time to make the initial connection

* automaticly updated release notes for mega-20180322

* ESP32 fix

* [Command] Parsing improvement for commands

Use more intelligent parsing of commands and switch statement to improve speed

* automaticly updated release notes for mega-20180323

* [WiFi] Reverted those temp String uses for ssid/pass

Was introduced due to misunderstanding of reported issues with WiFi.

* [issue #1131] Add %unixtime%

Show the current time as [Unix time](https://en.wikipedia.org/wiki/Unix_time) (numbers of seconds that have elapsed since midnight 1970-01-01, UTC)

* [issue #1097] Call MQTTclient.loop() during deepsleep

The `MQTTclient.loop()` function should be called quite often.
This does the actual MQTT handling.
In normal operations, this is called quite frequently, but it should also be called when deepsleep is active and right before deepsleep is activated again.

* [P1] Support for latest standard

* [wifi] Event based connect/reconnect

Now using the core WiFiEvents to act on:

- connect
- disconnect
- gotIP

This will make polling for a status no longer needed.
It also allows to get a better understanding in why diconnects happen, since the disconnect reason is given in the events.
This extra information is also present on the information panel on the webinterface and also in the JSON output.

The entire connect/disconnect/reconnect is now done completely asynchronous and thus takes much less resources from the ESP.
A disconnect will now also send an event: "WiFi#Disconnected"

For deepsleep this means there has to be a minimum awake time set and perhaps use rules to set the ESP into sleep again when done.
Typical connection times to an accesspoint are about 3 seconds + about 1 second for DHCP.

This also resolves the issues where services my try to connect while there is a WiFi connection, but not yet an IP address set.

I already noticed a lot of NTP servers from pool.ntp.org are non responsive the last few weeks, so that may still take some time, but that's another issue.

* automaticly updated release notes for mega-20180324

* [NTP] Speedup NTP again with async WiFi

Previously it would only start calling "now" when the WiFi was already setup.
And in calling `now()`, a call to an NTP server is being made. When this fails, retry again in a minute.
But now the WiFi initialization is asynchronous, so the first NTP query was already failing and thus the retry is already set to a minute.

This is fixed now and also the pool.ntp.org will pick a random one from 0...3 (.pool.ntp.org).
The DNS queries from this pool change about every minute, so if you want to retry because one of the servers is offline, you should try one from the other `N.pool.ntp.org` or else you have to wait for another minute.

* - fix for #1170 - uservar not setted on encwrite

* automaticly updated release notes for mega-20180326

* [issue #1174] Show degree sign via external writes to LCD

Fix suggested by [elmicha](#1174 (comment))

* [ESP32] Event driven WiFi for ESP32

Not tested, just got some inspiration by these files:

- https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/examples/WiFiClientEvents/WiFiClientEvents.ino
- https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/src/WiFiGeneric.cpp
- https://github.com/espressif/arduino-esp32/blob/master/tools/sdk/include/esp32/esp_event.h

* automaticly updated release notes for mega-20180327

* Fix nesting level check

* [Build] Cleanup/split builds using defines

See PR #1034 and #1040 made by @soif

* [build] Disabled a few PlatformIO profiles for now.

There were way too many.
Just placed them in comments and Travis had already built them all to test first.

* automaticly updated release notes for mega-20180328

* [Arduino IDE] Revert changes in include paths

Were changed to be able to test the PlatformIO feature to compile only files that are actually used.
Apparently the Arduino IDE cannot find the files anymore because that IDE needs the parent directory to be named as the main project file, not "src"

* automaticly updated release notes for mega-20180329
@DittelHome DittelHome mentioned this pull request Apr 16, 2018
TD-er pushed a commit that referenced this pull request Apr 18, 2018
@Oxyandy Oxyandy mentioned this pull request Apr 27, 2018
TD-er pushed a commit that referenced this pull request Jun 22, 2020
Change FormSubHeader to distinguish settings between IP of LAN or WiFi
TD-er pushed a commit that referenced this pull request Sep 24, 2020
TD-er added a commit that referenced this pull request Nov 9, 2022
Logs from test node:
```
120 : Info   : WIFI : Set WiFi to STA
6940 : Info   : WIFI : Set WiFi to OFF
7160 : Info   :

INIT : Booting version: ESP_Easy_mega_20221109_max_ESP32_16M8M_LittleFS_ETH, (Self built) build/swap_alt_wifi_03483b7 (ESP32 SDK v4.4.3.6)
7162 : Info   : INIT : Free RAM:247644
7163 : Info   : INIT : Cold Boot - Restart Reason: CPU0: Vbat power on reset CPU1: for APP CPU, reseted by PRO CPU
7164 : Info   : FS   : Mounting...
7196 : Info   : FS   : Mount successful, used 163840 bytes of 8318976
7226 : Info   : CRC  : Settings CRC           ...OK
7254 : Info   : CRC  : SecuritySettings CRC   ...OK
7282 : Error  : ExtRTC: Cannot get time from external time source
7284 : Info   : INIT : I2C
7286 : Info   : INIT : SPI not enabled
7287 : Info   : ExtRTC: Read external time source: 1667995774
7288 : Info   : Time : Set Ext. Time Source: Ext. RTC at boot time: 1667995774
7298 : Info   : Time set to 1667995774.000
7300 : Info   : Current Time Zone:  DST time start: 2022-03-27 02:00:00 offset: 120 min STD time start: 2022-10-30 03:00:00 offset: 60 min
7302 : Info   : Local time: 2022-11-09 13:09:34
7304 : Info   : WiFi : Best AP candidate: Lurch4 CC:CE:1E:13:B7:58 Ch:1 (-43dBm) WPA2/PSK bgn
7405 : Info   : WIFI : Set WiFi to STA
7417 : Info   : WiFi : Event STA Started
7518 : Info   : WiFi : Start network scan all channels
13934 : Info   : WiFi : Scan finished, found: 13
13936 : Info   : WiFi : Best AP candidate: Lurch4 CC:CE:1E:13:B7:58 Ch:1 (-45dBm) WPA2/PSK bgn
13938 : Info   : WiFi : Added known candidate, try to connect
13939 : Info   : WIFI : Connecting Lurch4 CC:CE:1E:13:B7:58 Ch:1 (-45dBm) WPA2/PSK bgn attempt #0
13946 : Info   : WIFI : Arduino wifi status: WL_DISCONNECTED 6 ESPeasy internal wifi status: DISCONNECTED
14048 : Info   : WIFI : Set WiFi to AP+STA
14418 : Info   : WiFi : Event AP Started
14428 : Info   : WiFi : Event STA Stopped
14978 : Info   : WiFi : Event AP Stopped
14979 : Info   : WiFi : Event AP Started
14979 : Info   : WIFI : AP Mode ssid will be MAX-ESP32-14 with address 192.168.4.1
14981 : Info   : WIFI : Disconnected! Reason: '(202) Auth fail' Connected for 486 ms
14981 : Info   : WIFI : Arduino wifi status: WL_NO_SHIELD 255 ESPeasy internal wifi status: DISCONNECTED
15082 : Info   : WIFI : Set WiFi to OFF
15086 : Info   : WiFi : Event AP Stopped
15202 : Info   : INIT : Free RAM:239344
22073 : Info   : INFO : Plugins: 130 [Normal][MAX ESP32] (ESP32 SDK v4.4.3.6)
22075 : Info   : EVENT: System#Wake
22232 : Info   : WIFI : Set WiFi to STA
22244 : Info   : WiFi : Event STA Started
22344 : Info   : WiFi : Start network scan all channels
28760 : Info   : WiFi : Best AP candidate: Lurch4 CC:CE:1E:13:B7:58 Ch:1 (-45dBm) WPA2/PSK bgn
28762 : Info   : WiFi : Scan finished, found: 13
28764 : Info   : WiFi : Best AP candidate: Lurch4 CC:CE:1E:13:B7:58 Ch:1 (-43dBm) WPA2/PSK bgn
28765 : Info   : WiFi : Added known candidate, try to connect
28866 : Info   : WIFI : Set WiFi to AP+STA
28870 : Info   : WiFi : Event AP Started
29431 : Info   : WiFi : Event AP Stopped
29432 : Info   : WiFi : Event AP Started
29433 : Info   : WIFI : AP Mode ssid will be MAX-ESP32-14 with address 192.168.4.1
29435 : Info   : EVENT: System#BootMode=1,1,0,0
29445 : Info   : Webserver: start
29446 : Info   : EVENT: System#Boot
29465 : Info   : EVENT: Time#Initialized
29631 : Info   : EVENT: WiFi#APmodeEnabled
29699 : Info   : EVENT: WiFi#Disconnected
29719 : Info   : EVENT: WiFi#APmodeDisabled
29823 : Info   : EVENT: WiFi#APmodeEnabled
30259 : Info   : EVENT: Clock#Time=Wed,13:09
30263 : Debug  : EVENT: Clock#Time=Wed,13:09 Processing time:5 milliSeconds
30268 : Debug  : WIFI : Disconnected: WiFi.status() = DISCONNECTED RSSI: 0 status: WL_DISCONNECTED 6
30805 : Info   : WD   : Uptime 0 ConnectFailures 0 FreeMem 189648 WiFiStatus WL_DISCONNECTED 6 ESPeasy internal wifi status: DISCONNECTED
31685 : Debug  : LoopStats: shortestLoop: 12879 longestLoop: 62002 avgLoopDuration: 16316.89 loopCounterMax: 2329 loopCounterLast: 135
31686 : Debug  : Scheduler stats: (called/tasks/max_length/idle%) 134/111/9/0.94
33950 : Info   : WIFI : Connecting Lurch4 CC:CE:1E:13:B7:58 Ch:1 (-43dBm) WPA2/PSK bgn attempt #1
33958 : Info   : WIFI : Arduino wifi status: WL_DISCONNECTED 6 ESPeasy internal wifi status: DISCONNECTED
34489 : Debug  : WIFI : Entering processConnect()
34491 : Info   : WIFI : Connected! AP: Lurch4 (CC:CE:1E:13:B7:58) Ch: 1 Duration: 530 ms
34497 : Info   : EVENT: Clock#Time=Wed,13:10
34501 : Debug  : EVENT: Clock#Time=Wed,13:10 Processing time:4 milliSeconds
34510 : Info   : EVENT: WiFi#ChangedAccesspoint
34515 : Debug  : EVENT: WiFi#ChangedAccesspoint Processing time:5 milliSeconds
34519 : Debug  : WIFI : Entering processGotIP()
34520 : Info   : WIFI : DHCP IP: 192.168.10.133 (MAX-ESP32-14) GW: 192.168.10.1 SN: 255.255.255.0   duration: 31 ms
34534 : Info   : EVENT: WiFi#ChangedWiFichannel
34539 : Debug  : EVENT: WiFi#ChangedWiFichannel Processing time:5 milliSeconds
34542 : Debug  : WiFi : WiFi services initialized
34542 : Info   : WIFI : Starting mDNS...
34549 : Info   : WIFI : mDNS started, with name: MAX-ESP32-14.local
34564 : Info   : EVENT: WiFi#Connected
34569 : Debug  : EVENT: WiFi#Connected Processing time:5 milliSeconds
34584 : Info   : UDP : Start listening on port 8266
34585 : Info   : firstLoopConnectionsEstablished
36293 : Debug  : NTP  : Time candidate: Unit: 242 "Sonoff POW R2 242" load: 15.3 RSSI: 0 ch: 1 dst: 0 time: 1667995802 ESPEasy p2p est. wander: 36718
38130 : Debug  : NTP  : Time candidate: Unit: 250 "Sonoff POW R2 250" load: 14.5 RSSI: 0 ch: 1 dst: 0 time: 1667995804 ESPEasy p2p est. wander: 36715
55539 : Debug  : NTP  : Time candidate: Unit: 23 "Sonoff POW R1" load: 14.5 RSSI: 0 ch: 1 dst: 0 time: 1667995822 NTP est. wander: 22512
60787 : Info   : WD   : Uptime 1 ConnectFailures 0 FreeMem 180176 WiFiStatus WL_CONNECTED 3 ESPeasy internal wifi status: Conn. IP Init
61675 : Debug  : LoopStats: shortestLoop: 89 longestLoop: 480035 avgLoopDuration: 237.58 loopCounterMax: 337078 loopCounterLast: 123361
61677 : Debug  : Scheduler stats: (called/tasks/max_length/idle%) 123360/2053/9/68.41
66294 : Info   : Time : Set Ext. Time Source: ESPEasy p2p time: 1667995833
66351 : Info   : NTP  : NTP replied: delay 31 mSec Accuracy increased by 0.392 seconds
66354 : Info   : ExtRTC: External time source set to: 1667995833
66355 : Info   : Time set to 1667995833.392 Time adjusted by 337.65 msec. Wander: 5717.7 ppm Source: NTP
66356 : Info   : Local time: 2022-11-09 13:10:33
66362 : Info   : EVENT: Time#Set
66367 : Debug  : EVENT: Time#Set Processing time:5 milliSeconds
```
RJLABS referenced this pull request in RJLABS/ESPEasy Jul 31, 2023
@mpl1337 mpl1337 mentioned this pull request Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant