Added Basic MQTT Support and JSON Deserialization
This commit is contained in:
40
ESP32_Utils.hpp
Normal file
40
ESP32_Utils.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
void ConnectWiFi_STA(bool useStaticIP = false)
|
||||
{
|
||||
Serial.println("");
|
||||
WiFi.mode(WIFI_STA);
|
||||
if(useStaticIP) {
|
||||
WiFi.config(ip, gateway, subnet);
|
||||
WiFi.setHostname(hostname);
|
||||
}
|
||||
WiFi.begin(ssid, password);
|
||||
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(100);
|
||||
Serial.print('.');
|
||||
}
|
||||
|
||||
Serial.println("");
|
||||
Serial.print("Iniciado STA:\t");
|
||||
Serial.println(ssid);
|
||||
Serial.print("IP address:\t");
|
||||
Serial.println(WiFi.localIP());
|
||||
}
|
||||
|
||||
void ConnectWiFi_AP(bool useStaticIP = false)
|
||||
{
|
||||
Serial.println("");
|
||||
WiFi.mode(WIFI_AP);
|
||||
while(!WiFi.softAP(ssid, password))
|
||||
{
|
||||
Serial.println(".");
|
||||
delay(100);
|
||||
}
|
||||
|
||||
if(useStaticIP) WiFi.softAPConfig(ip, gateway, subnet);
|
||||
|
||||
Serial.println("");
|
||||
Serial.print("Iniciado AP:\t");
|
||||
Serial.println(ssid);
|
||||
Serial.print("IP address:\t");
|
||||
Serial.println(WiFi.softAPIP());
|
||||
}
|
||||
Reference in New Issue
Block a user