mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 12:05:51 +01:00
various small fixes
- clean up webproxy getExtUrl - bugfix init multicast on wifi reconnect - add ip address of remote AP that's taken over a tag - renamed button 'edit contentFS' to 'file system'
This commit is contained in:
@@ -16,7 +16,7 @@ extern void processDataReq(struct espAvailDataReq* adr, bool local);
|
|||||||
extern bool sendTagCommand(const uint8_t* dst, uint8_t cmd, bool local);
|
extern bool sendTagCommand(const uint8_t* dst, uint8_t cmd, bool local);
|
||||||
extern bool sendAPSegmentedData(const uint8_t* dst, String data, uint16_t icons, bool inverted, bool local);
|
extern bool sendAPSegmentedData(const uint8_t* dst, String data, uint16_t icons, bool inverted, bool local);
|
||||||
extern bool showAPSegmentedInfo(const uint8_t* dst, bool local);
|
extern bool showAPSegmentedInfo(const uint8_t* dst, bool local);
|
||||||
extern void updateTaginfoitem(struct TagInfo* taginfoitem);
|
extern void updateTaginfoitem(struct TagInfo* taginfoitem, IPAddress remoteIP);
|
||||||
bool checkMirror(struct tagRecord* taginfo, struct pendingData* pending);
|
bool checkMirror(struct tagRecord* taginfo, struct pendingData* pending);
|
||||||
|
|
||||||
void refreshAllPending();
|
void refreshAllPending();
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
void handleSysinfoRequest(AsyncWebServerRequest* request);
|
void handleSysinfoRequest(AsyncWebServerRequest* request);
|
||||||
void handleCheckFile(AsyncWebServerRequest* request);
|
void handleCheckFile(AsyncWebServerRequest* request);
|
||||||
void handleGetExtUrl(AsyncWebServerRequest* request);
|
|
||||||
void handleLittleFSUpload(AsyncWebServerRequest* request, String filename, size_t index, uint8_t* data, size_t len, bool final);
|
void handleLittleFSUpload(AsyncWebServerRequest* request, String filename, size_t index, uint8_t* data, size_t len, bool final);
|
||||||
void handleUpdateOTA(AsyncWebServerRequest* request);
|
void handleUpdateOTA(AsyncWebServerRequest* request);
|
||||||
void firmwareUpdateTask(void* parameter);
|
void firmwareUpdateTask(void* parameter);
|
||||||
|
|||||||
@@ -140,7 +140,6 @@ void setup() {
|
|||||||
updateBrightnessFromConfig();
|
updateBrightnessFromConfig();
|
||||||
|
|
||||||
init_web();
|
init_web();
|
||||||
init_udp();
|
|
||||||
|
|
||||||
#ifdef HAS_RGB_LED
|
#ifdef HAS_RGB_LED
|
||||||
rgbIdle();
|
rgbIdle();
|
||||||
|
|||||||
@@ -324,8 +324,8 @@ void prepareExternalDataAvail(struct pendingData* pending, IPAddress remoteIP) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
taginfo->contentMode = 12;
|
// taginfo->contentMode = 12;
|
||||||
taginfo->nextupdate = 3216153600;
|
// taginfo->nextupdate = 3216153600;
|
||||||
checkMirror(taginfo, pending);
|
checkMirror(taginfo, pending);
|
||||||
sendDataAvail(pending);
|
sendDataAvail(pending);
|
||||||
|
|
||||||
@@ -616,7 +616,7 @@ bool sendTagCommand(const uint8_t* dst, uint8_t cmd, bool local) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateTaginfoitem(struct TagInfo* taginfoitem) {
|
void updateTaginfoitem(struct TagInfo* taginfoitem, IPAddress remoteIP) {
|
||||||
tagRecord* taginfo = tagRecord::findByMAC(taginfoitem->mac);
|
tagRecord* taginfo = tagRecord::findByMAC(taginfoitem->mac);
|
||||||
|
|
||||||
if (taginfo == nullptr) {
|
if (taginfo == nullptr) {
|
||||||
@@ -647,7 +647,7 @@ void updateTaginfoitem(struct TagInfo* taginfoitem) {
|
|||||||
char hexmac[17];
|
char hexmac[17];
|
||||||
mac2hex(taginfo->mac, hexmac);
|
mac2hex(taginfo->mac, hexmac);
|
||||||
if (taginfo->contentMode != 12 && taginfoitem->contentMode != 12) {
|
if (taginfo->contentMode != 12 && taginfoitem->contentMode != 12) {
|
||||||
wsLog("Remote AP takes control over tag " + String(hexmac));
|
wsLog("Remote AP at " + remoteIP.toString() + " takes control over tag " + String(hexmac));
|
||||||
taginfo->contentMode = 12;
|
taginfo->contentMode = 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,35 +81,6 @@ void handleCheckFile(AsyncWebServerRequest* request) {
|
|||||||
request->send(200, "application/json", jsonResponse);
|
request->send(200, "application/json", jsonResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleGetExtUrl(AsyncWebServerRequest* request) {
|
|
||||||
if (request->hasParam("url")) {
|
|
||||||
const String url = request->getParam("url")->value();
|
|
||||||
HTTPClient http;
|
|
||||||
http.begin(url);
|
|
||||||
http.setConnectTimeout(5000);
|
|
||||||
http.setFollowRedirects(HTTPC_FORCE_FOLLOW_REDIRECTS);
|
|
||||||
const int httpResponseCode = http.GET();
|
|
||||||
if (httpResponseCode > 0) {
|
|
||||||
Serial.println(httpResponseCode);
|
|
||||||
const String contentType = http.header("Content-Type");
|
|
||||||
const size_t contentLength = http.getSize();
|
|
||||||
if (contentLength > 0) {
|
|
||||||
String content = http.getString();
|
|
||||||
AsyncWebServerResponse* response = request->beginResponse(200, contentType, content);
|
|
||||||
request->send(response);
|
|
||||||
} else {
|
|
||||||
request->send(500, "text/plain", "no size header");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
request->send(httpResponseCode, "text/plain", "Failed to fetch URL");
|
|
||||||
wsSerial(http.errorToString(httpResponseCode));
|
|
||||||
}
|
|
||||||
http.end();
|
|
||||||
} else {
|
|
||||||
request->send(400, "text/plain", "Missing 'url' parameter");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleLittleFSUpload(AsyncWebServerRequest* request, String filename, size_t index, uint8_t* data, size_t len, bool final) {
|
void handleLittleFSUpload(AsyncWebServerRequest* request, String filename, size_t index, uint8_t* data, size_t len, bool final) {
|
||||||
bool error = false;
|
bool error = false;
|
||||||
if (!index) {
|
if (!index) {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ void UDPcomm::init() {
|
|||||||
void UDPcomm::processPacket(AsyncUDPPacket packet) {
|
void UDPcomm::processPacket(AsyncUDPPacket packet) {
|
||||||
|
|
||||||
if (config.runStatus == RUNSTATUS_STOP) return;
|
if (config.runStatus == RUNSTATUS_STOP) return;
|
||||||
|
IPAddress senderIP = packet.remoteIP();
|
||||||
|
|
||||||
switch (packet.data()[0]) {
|
switch (packet.data()[0]) {
|
||||||
case PKT_AVAIL_DATA_INFO: {
|
case PKT_AVAIL_DATA_INFO: {
|
||||||
@@ -70,12 +71,10 @@ void UDPcomm::processPacket(AsyncUDPPacket packet) {
|
|||||||
pendingData pending;
|
pendingData pending;
|
||||||
memset(&pending, 0, sizeof(pendingData));
|
memset(&pending, 0, sizeof(pendingData));
|
||||||
memcpy(&pending, &packet.data()[1], std::min(packet.length() - 1, sizeof(pendingData)));
|
memcpy(&pending, &packet.data()[1], std::min(packet.length() - 1, sizeof(pendingData)));
|
||||||
prepareExternalDataAvail(&pending, packet.remoteIP());
|
prepareExternalDataAvail(&pending, senderIP);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PKT_APLIST_REQ: {
|
case PKT_APLIST_REQ: {
|
||||||
IPAddress senderIP = packet.remoteIP();
|
|
||||||
|
|
||||||
APlist APitem;
|
APlist APitem;
|
||||||
APitem.src = WiFi.localIP();
|
APitem.src = WiFi.localIP();
|
||||||
strcpy(APitem.alias, config.alias);
|
strcpy(APitem.alias, config.alias);
|
||||||
@@ -103,10 +102,10 @@ void UDPcomm::processPacket(AsyncUDPPacket packet) {
|
|||||||
case PKT_TAGINFO: {
|
case PKT_TAGINFO: {
|
||||||
uint16_t syncversion = (packet.data()[2] << 8) | packet.data()[1];
|
uint16_t syncversion = (packet.data()[2] << 8) | packet.data()[1];
|
||||||
if (syncversion != SYNC_VERSION) {
|
if (syncversion != SYNC_VERSION) {
|
||||||
wsErr("Got a packet from " + packet.remoteIP().toString() + " with mismatched udp sync version. Update firmware!");
|
wsErr("Got a packet from " + senderIP.toString() + " with mismatched udp sync version. Update firmware!");
|
||||||
} else {
|
} else {
|
||||||
TagInfo* taginfoitem = (TagInfo*)&packet.data()[1];
|
TagInfo* taginfoitem = (TagInfo*)&packet.data()[1];
|
||||||
updateTaginfoitem(taginfoitem);
|
updateTaginfoitem(taginfoitem, senderIP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -497,7 +497,6 @@ void init_web() {
|
|||||||
|
|
||||||
server.on("/sysinfo", HTTP_GET, handleSysinfoRequest);
|
server.on("/sysinfo", HTTP_GET, handleSysinfoRequest);
|
||||||
server.on("/check_file", HTTP_GET, handleCheckFile);
|
server.on("/check_file", HTTP_GET, handleCheckFile);
|
||||||
server.on("/getexturl", HTTP_GET, handleGetExtUrl);
|
|
||||||
server.on("/rollback", HTTP_POST, handleRollback);
|
server.on("/rollback", HTTP_POST, handleRollback);
|
||||||
server.on("/update_actions", HTTP_POST, handleUpdateActions);
|
server.on("/update_actions", HTTP_POST, handleUpdateActions);
|
||||||
server.on("/update_ota", HTTP_POST, [](AsyncWebServerRequest *request) {
|
server.on("/update_ota", HTTP_POST, [](AsyncWebServerRequest *request) {
|
||||||
|
|||||||
@@ -200,6 +200,7 @@ void WifiManager::WiFiEvent(WiFiEvent_t event) {
|
|||||||
break;
|
break;
|
||||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
|
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
|
||||||
eventname = "Obtained IP address: " + String(WiFi.localIP().toString().c_str());
|
eventname = "Obtained IP address: " + String(WiFi.localIP().toString().c_str());
|
||||||
|
init_udp();
|
||||||
break;
|
break;
|
||||||
case ARDUINO_EVENT_WIFI_STA_LOST_IP:
|
case ARDUINO_EVENT_WIFI_STA_LOST_IP:
|
||||||
eventname = "Lost IP address and IP address is reset to 0";
|
eventname = "Lost IP address and IP address is reset to 0";
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ to save file system space">
|
|||||||
<div><span id="runstate"></div>
|
<div><span id="runstate"></div>
|
||||||
<div><span id="apstatecolor">⬤</span> <span id="apstate">loading</span></div>
|
<div><span id="apstatecolor">⬤</span> <span id="apstate">loading</span></div>
|
||||||
<div><span id="apconfigbutton">AP config</span></div>
|
<div><span id="apconfigbutton">AP config</span></div>
|
||||||
<div><a href="/edit" target="littlefs" class="filebutton">edit contentFS</a></div>
|
<div><a href="/edit" target="littlefs" class="filebutton">file system</a></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="filterOptions">
|
<div id="filterOptions">
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ export async function updateESP(fileUrl, showConfirm) {
|
|||||||
|
|
||||||
while (retryCount < maxRetries) {
|
while (retryCount < maxRetries) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch("https://openepaperlink.eu/getupdate/?url=" + fileUrl);
|
const response = await fetch("https://openepaperlink.eu/getupdate/?url=" + fileUrl + "&env=" + env);
|
||||||
const responseBody = await response.text();
|
const responseBody = await response.text();
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error("Network response was not OK: " + responseBody);
|
throw new Error("Network response was not OK: " + responseBody);
|
||||||
|
|||||||
Reference in New Issue
Block a user