mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 10:06:07 +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 sendAPSegmentedData(const uint8_t* dst, String data, uint16_t icons, bool inverted, 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);
|
||||
|
||||
void refreshAllPending();
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
void handleSysinfoRequest(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 handleUpdateOTA(AsyncWebServerRequest* request);
|
||||
void firmwareUpdateTask(void* parameter);
|
||||
|
||||
@@ -140,7 +140,6 @@ void setup() {
|
||||
updateBrightnessFromConfig();
|
||||
|
||||
init_web();
|
||||
init_udp();
|
||||
|
||||
#ifdef HAS_RGB_LED
|
||||
rgbIdle();
|
||||
|
||||
@@ -324,8 +324,8 @@ void prepareExternalDataAvail(struct pendingData* pending, IPAddress remoteIP) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
taginfo->contentMode = 12;
|
||||
taginfo->nextupdate = 3216153600;
|
||||
// taginfo->contentMode = 12;
|
||||
// taginfo->nextupdate = 3216153600;
|
||||
checkMirror(taginfo, 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);
|
||||
|
||||
if (taginfo == nullptr) {
|
||||
@@ -647,7 +647,7 @@ void updateTaginfoitem(struct TagInfo* taginfoitem) {
|
||||
char hexmac[17];
|
||||
mac2hex(taginfo->mac, hexmac);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,35 +81,6 @@ void handleCheckFile(AsyncWebServerRequest* request) {
|
||||
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) {
|
||||
bool error = false;
|
||||
if (!index) {
|
||||
|
||||
@@ -43,6 +43,7 @@ void UDPcomm::init() {
|
||||
void UDPcomm::processPacket(AsyncUDPPacket packet) {
|
||||
|
||||
if (config.runStatus == RUNSTATUS_STOP) return;
|
||||
IPAddress senderIP = packet.remoteIP();
|
||||
|
||||
switch (packet.data()[0]) {
|
||||
case PKT_AVAIL_DATA_INFO: {
|
||||
@@ -70,12 +71,10 @@ void UDPcomm::processPacket(AsyncUDPPacket packet) {
|
||||
pendingData pending;
|
||||
memset(&pending, 0, sizeof(pendingData));
|
||||
memcpy(&pending, &packet.data()[1], std::min(packet.length() - 1, sizeof(pendingData)));
|
||||
prepareExternalDataAvail(&pending, packet.remoteIP());
|
||||
prepareExternalDataAvail(&pending, senderIP);
|
||||
break;
|
||||
}
|
||||
case PKT_APLIST_REQ: {
|
||||
IPAddress senderIP = packet.remoteIP();
|
||||
|
||||
APlist APitem;
|
||||
APitem.src = WiFi.localIP();
|
||||
strcpy(APitem.alias, config.alias);
|
||||
@@ -103,10 +102,10 @@ void UDPcomm::processPacket(AsyncUDPPacket packet) {
|
||||
case PKT_TAGINFO: {
|
||||
uint16_t syncversion = (packet.data()[2] << 8) | packet.data()[1];
|
||||
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 {
|
||||
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("/check_file", HTTP_GET, handleCheckFile);
|
||||
server.on("/getexturl", HTTP_GET, handleGetExtUrl);
|
||||
server.on("/rollback", HTTP_POST, handleRollback);
|
||||
server.on("/update_actions", HTTP_POST, handleUpdateActions);
|
||||
server.on("/update_ota", HTTP_POST, [](AsyncWebServerRequest *request) {
|
||||
|
||||
@@ -200,6 +200,7 @@ void WifiManager::WiFiEvent(WiFiEvent_t event) {
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
|
||||
eventname = "Obtained IP address: " + String(WiFi.localIP().toString().c_str());
|
||||
init_udp();
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_STA_LOST_IP:
|
||||
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="apstatecolor">⬤</span> <span id="apstate">loading</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 id="filterOptions">
|
||||
<div>
|
||||
|
||||
@@ -256,7 +256,7 @@ export async function updateESP(fileUrl, showConfirm) {
|
||||
|
||||
while (retryCount < maxRetries) {
|
||||
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();
|
||||
if (!response.ok) {
|
||||
throw new Error("Network response was not OK: " + responseBody);
|
||||
|
||||
Reference in New Issue
Block a user