I'm trying to make this ESP8266 code suitable so that I am able to connect it to the school internet. However, I only know of inputting the network name and password on the code, however, to access my schools internet, I need to input the network name, my student username and my student password. My question is, what sort of line of code would I write to include the student username input. The lines of code I currently have regarding WIFI credentials are the following, what must I add?
///Connect SCL to D1 and Connect SDA to D2
/* WiFi credentials */
char ssid[] = "enter wifi network";
char pass[] = "enter username";
Maybe it's a captive portal: like when you use WiFi at a hotel. Not the crappy completely free and open one in the lobby, but the one in the rooms, that they can charge for. You connect to the Access Point as usual with the SSID (with or without a password), but before you can actually do anything, you get an HTML page where you type in extra stuff like the hotel room number; or the student name and their password in this case.
WiFi doesn't recognize the device (more on this later)
WiFi lies and says, "Oh that's at this particular IP address", e.g. 4.3.2.1 (which is actually owned by Google, but not relevant)
Browser redirects to that address
WiFi recognizes 4.3.2.1 and returns a regular HTML page (and however many files are required to make it work) to ask for the extra info
You type in the info and submit the form, just like any other. Typically this is a regular POST with Content-Type application/x-www-form-urlencoded; but who knows, maybe the page uses Ajax and makes API calls.
If valid, WiFi makes note of the device -- maybe its MAC address -- and keeps it for a day or week or whatever.
WiFi replies, "Oh example.com is actually over here" with the real address
Browser tries again
Now you are allowed through
One can figure out how this works with a laptop and a browser's Network monitor. Best case scenario, you determine that you can unilaterally send a POST to the right URL with the expected payload, and do that as often as you want. That's one extra step:
WiFi.begin
HTTPClient.begin, maybe some headers, and POST <--- this one
Do what you were going to do
It gets harder: you have to simulate being a browser
Make a request. If it works, great; if not
Receive that portal HTML. Maybe you don't actually have to read it every time, and you already figured out what it is asking for (which can break if they update the page)
Do that POST in response
More possible complications
They put some token values in the HTML form that are expected to be returned in the POST. Now you have to parse it.
The page requires JavaScript to function -- either a little or a lot -- in a critical part
Maybe they can allow-list your specific devices semi-permanently.