ip
This commit is contained in:
parent
f161e467bf
commit
9350b6f77d
7
.vscode/arduino.json
vendored
7
.vscode/arduino.json
vendored
@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"output": "Output",
|
|
||||||
"port": "/dev/ttyUSB0",
|
|
||||||
"board": "esp8266:esp8266:generic",
|
"board": "esp8266:esp8266:generic",
|
||||||
"configuration": "CpuFrequency=80,FlashFreq=40,FlashMode=qio,UploadSpeed=921600,FlashSize=4M2M,ResetMethod=ck,Debug=Disabled,DebugLevel=None____",
|
"configuration": "CpuFrequency=80,FlashFreq=40,FlashMode=qio,UploadSpeed=115200,FlashSize=512K0,ResetMethod=ck,Debug=Disabled,DebugLevel=None____",
|
||||||
"sketch": "frontend.ino"
|
"sketch": "frontend.ino",
|
||||||
|
"port": "/dev/ttyUSB0"
|
||||||
}
|
}
|
12
frontend.ino
12
frontend.ino
@ -10,7 +10,7 @@
|
|||||||
String inTemp,outTemp,pressure,humid;
|
String inTemp,outTemp,pressure,humid;
|
||||||
const unsigned short int onTime=6, offTime=23, beepDelay=60, timeOffset=3;
|
const unsigned short int onTime=6, offTime=23, beepDelay=60, timeOffset=3;
|
||||||
short int lastBeep;
|
short int lastBeep;
|
||||||
const String httpAddr="http://192.168.100.101:1880";
|
const String httpAddr="http://192.168.100.100:1880";
|
||||||
|
|
||||||
WiFiUDP ntpUDP;
|
WiFiUDP ntpUDP;
|
||||||
NTPClient timeClient(ntpUDP);
|
NTPClient timeClient(ntpUDP);
|
||||||
@ -45,15 +45,14 @@ void loop(){
|
|||||||
netTasks();
|
netTasks();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
delay(750);
|
delay(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void netTasks() {
|
void netTasks() {
|
||||||
HTTPClient http;
|
HTTPClient http;
|
||||||
WiFi.forceSleepWake();
|
WiFi.forceSleepWake();
|
||||||
wifiConnect();
|
|
||||||
if (WiFi.status() != WL_CONNECTED) {
|
if (WiFi.status() != WL_CONNECTED) {
|
||||||
wifiConnect();
|
wifiConnect(false);
|
||||||
}
|
}
|
||||||
http.begin(httpAddr+"/inTemp");
|
http.begin(httpAddr+"/inTemp");
|
||||||
if (http.GET() < 0) //IDK why the fuck i cant getString without this check
|
if (http.GET() < 0) //IDK why the fuck i cant getString without this check
|
||||||
@ -141,21 +140,18 @@ bool nightMode() {
|
|||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void wifiConnect() {
|
void wifiConnect(bool boot) {
|
||||||
int beginMillis = millis();
|
int beginMillis = millis();
|
||||||
WiFi.begin(ssid, password);
|
WiFi.begin(ssid, password);
|
||||||
while (WiFi.status() != WL_CONNECTED && millis() - beginMillis < 30000) {
|
while (WiFi.status() != WL_CONNECTED && millis() - beginMillis < 30000) {
|
||||||
delay(250);
|
delay(250);
|
||||||
displayStatus(1);
|
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
if (WiFi.status() != WL_CONNECTED) {
|
if (WiFi.status() != WL_CONNECTED) {
|
||||||
displayStatus(2);
|
|
||||||
delay(10000);
|
delay(10000);
|
||||||
ESP.reset();
|
ESP.reset();
|
||||||
} else {
|
} else {
|
||||||
Serial.print("Connected to " + String(ssid) + "; IP address: ");
|
Serial.print("Connected to " + String(ssid) + "; IP address: ");
|
||||||
Serial.println(WiFi.localIP());
|
Serial.println(WiFi.localIP());
|
||||||
displayStatus(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user