mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-28 01:25:49 +03:00
[GH-ISSUE #1211] How to set SSID and Password programmatically ? #1030
Labels
No labels
📶 WiFi
🕸️ HTTP
Branch
DEV Help Wanted
Discussion
Documentation
ESP32
Example
Good First Issue
Hotfix
In Progress
Incomplete
Needs Feeback
Priority
QA
Question
Task
Upstream/Dependancy
bug
duplicate
enhancement
invalid
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/WiFiManager#1030
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sn00zerman on GitHub (Feb 10, 2021).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1211
Hardware
WiFimanager Branch/Release: Development
Esp32:
Hardware: Lilygo TTGO T8
Core Version: 2.4.0, staging
Description:
I'm looking for a way to "pre-fill" the SSID and Password field,
when the captive portal shows up.
(Like one would do when presenting extra parameters, you also have a way to fill it in from the software-side ...)
Additional libraries:
#include "WiFi.h"
#include "HTTPClient.h"
#include "WiFiManager.h"
#include "WiFiClient.h"
#include "WebServer.h"
#include "ESPmDNS.h"
#include "Update.h"
@sn00zerman commented on GitHub (Feb 12, 2021):
I managed to solve my own problem :-) (after a good night-sleep, I could think more clear again)
I added 2 parameters, of type "hidden": hidden_s and hidden_p (hidden_s contains programmatically SSID, and hidden_p the password)
I added a function in the HTTP_SCRIPT[] in strings_en.h, just before the tag:
"function myHidden()\n"
"{\n"
" var txt_s = document.getElementById('s');\n"
" var txt_hidden_s = document.getElementById('hidden_s');\n"
" var txt_p = document.getElementById('p');\n"
" var txt_hidden_p = document.getElementById('hidden_p');\n"
" txt_s.value = txt_hidden_s.value;\n"
" txt_p.value = txt_hidden_p.value;\n"
"}\n"
Everytime, the page loads, it passes the data from the hidden field, into the s and p field :-)
@tablatronix commented on GitHub (Feb 12, 2021):
It will use the creds from the ESP and show them, so just save them to the esp. Are you obtaining them from somewhere else?
@sn00zerman commented on GitHub (Feb 12, 2021):
I needed a way to programmatically set them in the captive portal, giving the user the possibility to "adjust" these settings and save them. I obtain them trough an algorithm, AP's are taken offline, "re-calculated" and taken back online, in a 24hour cycle ...
But my problem is solved now, with the hidden_s and hidden_p :-)
@tablatronix commented on GitHub (Feb 12, 2021):
I mean why not just do WiFi.begin(SSID,PSK);
@tablatronix commented on GitHub (Feb 12, 2021):
fyi I added this a few days ago