You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
3.2 KiB
99 lines
3.2 KiB
void ntp()
|
|
{ Serial1.setTimeout(8000);
|
|
char c1 ;
|
|
char c2 ;
|
|
|
|
int x1, y1;
|
|
bool ter = 0;
|
|
myGLCD.setColor(255, 255, 255); //белые буквы ком строки
|
|
myGLCD.setBackColor(0, 0, 155); //фон цифр
|
|
myGLCD.setFont(BigFont);
|
|
digitalWrite(14, LOW);
|
|
myGLCD.print(" NTP " , 280, 457);
|
|
delay(3000);
|
|
digitalWrite(14, HIGH);//reset WIFI
|
|
myGLCD.print(" connecting " , 280, 457);
|
|
delay(3000);
|
|
|
|
int i = 0;
|
|
int q = 0;
|
|
myGLCD.print(" WIFI connect " , 240, 457);
|
|
//***********************************************************************************************************
|
|
while (Serial1.available()) {
|
|
if (Serial1.find("IP"))
|
|
{
|
|
|
|
int ip1 = Serial1.parseInt();
|
|
|
|
int ip2 = Serial1.parseInt();
|
|
|
|
int ip3 = Serial1.parseInt();
|
|
|
|
int ip4 = Serial1.parseInt();
|
|
|
|
// Serial1.read();
|
|
// String data1 = "IP:" + String(ip1) + "." + String(ip2) + "." + String(ip3) + "." + String(ip4) + " ";
|
|
String data1;
|
|
data1 += ip1;
|
|
data1 += ".";
|
|
data1 += ip2;
|
|
data1 += ".";
|
|
data1 += ip3;
|
|
data1 += ".";
|
|
data1 += ip4;
|
|
data1 += " ";
|
|
myGLCD.print(data1 , 240, 457);
|
|
}
|
|
// myGLCD.print(String(c1) ,500, 457);
|
|
// myGLCD.print(String(c2) ,520, 457);
|
|
|
|
}
|
|
//*********************************************************************************************************
|
|
// delay(3000);
|
|
Serial1.print("7");//проверка подключения к точке доступа если ответ больше 0 то подключились
|
|
delay(2000);
|
|
myGLCD.print(" " , 250, 457);
|
|
while (Serial1.available()) {
|
|
if (Serial1.find("7+"))
|
|
{ myGLCD.print(" read data " , 240, 457);
|
|
}
|
|
}
|
|
//******************************************************************************************************
|
|
//*********************************************************************************************************
|
|
Serial1.print("2");//проверка подключения к точке доступа если ответ больше 0 то подключились
|
|
delay(2000);
|
|
while (Serial1.available()) {
|
|
if (Serial1.find("2+"))
|
|
{ myGLCD.print(" read ntp " , 240, 457);
|
|
h1 = Serial1.parseInt();
|
|
m1 = Serial1.parseInt();
|
|
s1 = Serial1.parseInt();
|
|
day1 = Serial1.parseInt();
|
|
month1 = Serial1.parseInt() * (-1);
|
|
year1 = Serial1.parseInt() * (-1);
|
|
if ( year1 == 1970)
|
|
{
|
|
Serial1.print("2");
|
|
delay(2000);
|
|
myGLCD.print(" end read NTP1 " , 280, 457);
|
|
if (Serial1.find("2+"))
|
|
{
|
|
myGLCD.print(" read NTP2 " , 280, 457);
|
|
delay(1000);
|
|
h1 = Serial1.parseInt();
|
|
m1 = Serial1.parseInt();
|
|
s1 = Serial1.parseInt();
|
|
day1 = Serial1.parseInt();
|
|
month1 = Serial1.parseInt() * (-1);
|
|
year1 = Serial1.parseInt() * (-1);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
//******************************************************************************************************
|
|
myGLCD.print(" " , 240, 457);
|
|
String data = String(day1) + "/" + String(month1) + "/" + String(year1) + " ";
|
|
myGLCD.print(data , 300, 457);
|
|
|
|
}
|
|
|