Hello.
I'm new to Arduino development. I'm working on an ESP32 and trying to connect it to WiFi using a static ip. I'm able to connect using DHCP just fine using WiFi.begin(...).
I'm using this piece of documentation to base my code off of. I'm currently using this method to verify the WiFi was set up correctly:
void printWiFiStatus() {
// print your WiFi IP address
IPAddress ip = WiFi.localIP();
Serial.print(F("Module IP address: "));
Serial.println(ip);
Serial.flush();
// print your WiFi gateway
IPAddress gw = WiFi.gatewayIP();
Serial.print(F("Module gateway IP address: "));
Serial.println(gw);
Serial.flush();
// print your WiFi subnet mask
IPAddress sm = WiFi.subnetMask();
Serial.print(F("Module subnet mask: "));
Serial.println(sm);
Serial.flush();
// print the received signal strength
long rssi = WiFi.RSSI();
Serial.print(F("Module signal strength (RSSI): "));
Serial.print(rssi);
Serial.println(F(" dBm"));
Serial.flush();
}
The values that were being printed were definitely wrong and it took a little bit of trial and error to fix it:
WiFi.config(
config::STATIC_IP,
config::STATIC_GATEWAY,
config::STATIC_SUBNET_MASK,
config::DNS
);
This was the resulting output from Serial:
Module IP address: 192.168.1.100
Module gateway IP address: 192.168.1.1
Module subnet mask: 255.255.255.0
Module signal strength (RSSI): -61 dBm
My question is whether the order of the parameters depends on the board I'm deploying to or whether the documentation is incorrect. It's not enough that this is working just for this particular board. I'm trying to develop for a codebase that could potentially be deployed to several kinds of boards. Having to swap params around based on boards will get a little tidious...
I've also been told that setting the pin modes for the wifi module is a good best practice when writing board-agnostic code. I'm wonder if the pin modes affect the order of these parameters or if I were to screw up the pin modes whether that would also affect the order of the parameters. My current code doesn't bother with the pin modes, but that may be changing as my project progresses. Any advice or tips to that point would also be appreciated.