每10s刷新wifi
This commit is contained in:
@ -114,6 +114,11 @@ void TJC_Show::showInfo() {
|
||||
sendCommand(str);
|
||||
|
||||
// === wifi 页面信息 ===
|
||||
static unsigned long lastWiFiUpdateTime = 0; // 静态局部变量,保持状态
|
||||
const unsigned long wifiUpdateInterval = 10000; // 10秒更新间隔
|
||||
|
||||
unsigned long currentTime = millis();
|
||||
if (currentTime - lastWiFiUpdateTime >= wifiUpdateInterval) {
|
||||
char addr[64];
|
||||
IPAddress ip;
|
||||
|
||||
@ -131,6 +136,9 @@ void TJC_Show::showInfo() {
|
||||
|
||||
snprintf(addr, sizeof(addr), "wifi.qr0.txt=\"http://%d.%d.%d.%d/\"\xff\xff\xff", ip[0], ip[1], ip[2], ip[3]);
|
||||
sendCommand(addr);
|
||||
|
||||
lastWiFiUpdateTime = currentTime; // 更新最后更新时间
|
||||
}
|
||||
}
|
||||
// void TJC_Show::processSerial() {
|
||||
// #define FRAME_LENGTH 10
|
||||
|
||||
@ -198,7 +198,7 @@ void WebServer_Init(void) {
|
||||
String response = "<!DOCTYPE html><html><body><h2>Configuration Received</h2><p>Please wait while the device connects to WiFi...</p></body></html>";
|
||||
request->send(200, "text/html", response);
|
||||
});
|
||||
|
||||
// int32_t IRIS_Protocol_Pack(uint8_t Command,uint16_t LenthofIn, uint8_t *BufferIn, uint8_t *PackData);
|
||||
// 合并数据接口
|
||||
server.on("/data", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
//StaticJsonDocument<256> doc;
|
||||
@ -217,6 +217,12 @@ void WebServer_Init(void) {
|
||||
String json;
|
||||
serializeJson(doc, json);
|
||||
request->send(200, "application/json", json);
|
||||
// uint8_t *bufferfosend;
|
||||
// int lentofpack=IRIS_Protocol_Pack(0x00, json.length(), (uint8_t*)json.c_str(),bufferfosend);
|
||||
// Serial1.write(bufferfosend,lentofpack);
|
||||
// delete[] bufferfosend;
|
||||
|
||||
|
||||
});
|
||||
|
||||
// 设置Wiper值
|
||||
|
||||
Reference in New Issue
Block a user