WIFI credentials issue in a school

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";

" I need to input the network name, my student username and my student password" ... now where would you do that?

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.

That would depend on the rest of the code, which you forgot to post.

Here it is:

// Blynk - Version: Latest 
#define BLYNK_TEMPLATE_ID "TMPL5Ig6HuHG6"
#define BLYNK_TEMPLATE_NAME "ESP8266 BLYNK APP"
#define BLYNK_AUTH_TOKEN "A9AQ1nKYL8O7zcAvQ4qmIGEwnwJA73vH"
/*
 ESP8266 LoRa Gateway, receiver side

*/
#include <SPI.h>              // include libraries
#include <LoRa.h>
#include <Wire.h>
#include <BlynkSimpleEsp8266.h>

#define Nss 15 // D8 pin CS
#define rst 16 // D0 
#define dio0 2 // D4
int buzzer = D3;
char auth[] = "-HrsXL8bXKhJrZdFOmVQgK6VfzGoVQqv";

 ///Connect SCL to D1 and Connect SDA to D2
/* WiFi credentials */
char ssid[] = "enter wifi network";
char pass[] = "enter username";

byte MasterNode = 0xFF;     
byte Node1 = 0xBB;
String SenderNode = "";
String outgoing;              // outgoing message
byte msgCount = 0;            // count of outgoing messages
String incoming = "";
float ctemp; 
float ftemp; 



void setup() {
  Serial.begin(9600);                   // initialize serial
 LoRa.setPins(Nss, rst, dio0);

  if (!LoRa.begin(433E6)) {             // initialize ratio at 915 MHz
    Serial.println("LoRa init failed. Check your connections.");
    while (true);                       // if failed, do nothing
  }

 // Serial.println("LoRa init succeeded.");
   Blynk.begin(auth, ssid, pass);

}

void loop() {
  Blynk.run();
  // parse for a packet, and call onReceive with the result:
  onReceive(LoRa.parsePacket());
    
  }


void onReceive(int packetSize) {
  if (packetSize == 0) return;          // if there's no packet, return

  // read packet header bytes:
  int recipient = LoRa.read();          // recipient address
  byte sender = LoRa.read();            // sender address
  if( sender == 0XBB )
  SenderNode = "Node1:";
  byte incomingMsgId = LoRa.read();     // incoming msg ID
  byte incomingLength = LoRa.read();    // incoming msg length


  while (LoRa.available()) {
    incoming += (char)LoRa.read();
  }

  if (incomingLength != incoming.length()) {   // check length for error
    //Serial.println("error: message length does not match length");
    ;
    return;                             // skip rest of function
  }

  // if the recipient isn't this device or broadcast,
  if (recipient != Node1 && recipient != MasterNode) {
   // Serial.println("This message is not for me.");
    ;
    return;                             // skip rest of function
  }

  // if message is for this device, or broadcast, print details:
  //Serial.println("Received from: 0x" + String(sender, HEX));
  //Serial.println("Sent to: 0x" + String(recipient, HEX));
  //Serial.println("Message ID: " + String(incomingMsgId));
 // Serial.println("Message length: " + String(incomingLength));
 // Serial.println("Message: " + incoming);
  //Serial.println("RSSI: " + String(LoRa.packetRssi()));
 // Serial.println("Snr: " + String(LoRa.packetSnr()));
 // Serial.println();


 String q=getValue(incoming, ',', 0); 
 
String r =getValue(incoming, ',', 1); 
 
ctemp = q.toFloat();
 Serial.print(ctemp);
  Serial.println(" C");
ftemp = r.toFloat();
 Serial.print(ftemp);
  Serial.println(" F");
Blynk.virtualWrite(V1,ctemp);
 Blynk.virtualWrite(V2,ftemp);
 if (ctemp >= 45 )
 {
      Blynk.notify("Temperature Exceeded!!!"); 
      digitalWrite( buzzer, HIGH);
 }
  if (ctemp < 45 )
 {
      
      digitalWrite( buzzer, LOW);
 }
  

  //delay(1000);
incoming = "";

   
}


String getValue(String data, char separator, int index)
{
    int found = 0;
    int strIndex[] = { 0, -1 };
    int maxIndex = data.length() - 1;
 
    for (int i = 0; i <= maxIndex && found <= index; i++) {
        if (data.charAt(i) == separator || i == maxIndex) {
            found++;
            strIndex[0] = strIndex[1] + 1;
            strIndex[1] = (i == maxIndex) ? i+1 : i;
        }
    }
    return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
}

Not going to get very far until you answer post #2.

That's exactly the situation, any idea how I should alter the code so that it can be adapted to this situation?

Either ask the IT responsible person in your school to answer that question or pay "somebody" to ask that question for you.

OK, ty

A captive portal makes the WiFi hard to use for IoT -- which may be the point. If there is no alternative, then the way they work in general is:

  1. You connect to the WiFi
  2. Browser asks for something at www.example.com
  3. WiFi doesn't recognize the device (more on this later)
  4. 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)
  5. Browser redirects to that address
  6. 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
  7. 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.
  8. If valid, WiFi makes note of the device -- maybe its MAC address -- and keeps it for a day or week or whatever.
  9. WiFi replies, "Oh example.com is actually over here" with the real address
  10. Browser tries again
  11. 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:

  1. WiFi.begin
  2. HTTPClient.begin, maybe some headers, and POST <--- this one
  3. Do what you were going to do

It gets harder: you have to simulate being a browser

  1. Make a request. If it works, great; if not
  2. 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)
  3. 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.