mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 05:06:39 +01:00
previews now also show for tags connected to external AP; removed extra debug msg
This commit is contained in:
Binary file not shown.
@@ -11,7 +11,7 @@ extern bool prepareDataAvail(String& filename, uint8_t dataType, uint8_t dataTyp
|
||||
extern void prepareExternalDataAvail(struct pendingData* pending, IPAddress remoteIP);
|
||||
extern void processXferComplete(struct espXferComplete* xfc, bool local);
|
||||
extern void processXferTimeout(struct espXferComplete* xfc, bool local);
|
||||
extern void processDataReq(struct espAvailDataReq* adr, bool local);
|
||||
extern void processDataReq(struct espAvailDataReq* adr, bool local, IPAddress remoteIP = IPAddress(0, 0, 0, 0));
|
||||
extern void processTagReturnData(struct espTagReturnData* trd, uint8_t len, bool local);
|
||||
|
||||
extern bool sendTagCommand(const uint8_t* dst, uint8_t cmd, bool local, const uint8_t* payload = nullptr);
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
class tagRecord {
|
||||
public:
|
||||
tagRecord() : mac{0}, alias(""), lastseen(0), nextupdate(0), contentMode(0), pending(false), md5{0}, md5pending{0}, expectedNextCheckin(0), modeConfigJson(""), LQI(0), RSSI(0), temperature(0), batteryMv(0), hwType(0), wakeupReason(0), capabilities(0), lastfullupdate(0), isExternal(false), pendingIdle(0), hasCustomLUT(false), rotate(0), lut(0), tagSoftwareVersion(0), currentChannel(0), dataType(0), filename(""), data(nullptr), len(0) {}
|
||||
tagRecord() : mac{0}, alias(""), lastseen(0), nextupdate(0), contentMode(0), pending(false), md5{0}, md5pending{0}, expectedNextCheckin(0), modeConfigJson(""), LQI(0), RSSI(0), temperature(0), batteryMv(0), hwType(0), wakeupReason(0), capabilities(0), lastfullupdate(0), isExternal(false), apIp(IPAddress(0, 0, 0, 0)), pendingIdle(0), hasCustomLUT(false), rotate(0), lut(0), tagSoftwareVersion(0), currentChannel(0), dataType(0), filename(""), data(nullptr), len(0) {}
|
||||
|
||||
uint8_t mac[8];
|
||||
String alias;
|
||||
@@ -42,6 +42,7 @@ class tagRecord {
|
||||
uint8_t capabilities;
|
||||
uint32_t lastfullupdate;
|
||||
bool isExternal;
|
||||
IPAddress apIp;
|
||||
uint16_t pendingIdle;
|
||||
bool hasCustomLUT;
|
||||
uint8_t rotate;
|
||||
|
||||
@@ -43,9 +43,7 @@ void contentRunner() {
|
||||
|
||||
for (tagRecord *taginfo : tagDB) {
|
||||
if (taginfo->RSSI && (now >= taginfo->nextupdate || taginfo->wakeupReason == WAKEUP_REASON_GPIO || taginfo->wakeupReason == WAKEUP_REASON_NFC) && config.runStatus == RUNSTATUS_RUN && Storage.freeSpace() > 31000 && !util::isSleeping(config.sleepTime1, config.sleepTime2)) {
|
||||
Serial.println("drawnew start");
|
||||
drawNew(taginfo->mac, (taginfo->wakeupReason == WAKEUP_REASON_GPIO), taginfo);
|
||||
Serial.println("drawnew end");
|
||||
taginfo->wakeupReason = 0;
|
||||
}
|
||||
|
||||
@@ -79,7 +77,6 @@ void contentRunner() {
|
||||
}
|
||||
|
||||
void checkVars() {
|
||||
Serial.println("checkvars begin");
|
||||
DynamicJsonDocument cfgobj(500);
|
||||
for (tagRecord *tag : tagDB) {
|
||||
if (tag->contentMode == 19) {
|
||||
@@ -113,7 +110,6 @@ void checkVars() {
|
||||
for (const auto &entry : varDB) {
|
||||
if (entry.second.changed) varDB[entry.first].changed = false;
|
||||
}
|
||||
Serial.println("checkvars end");
|
||||
}
|
||||
|
||||
/// @brief Draw a counter
|
||||
|
||||
@@ -110,6 +110,7 @@ void prepareDataAvail(uint8_t* data, uint16_t len, uint8_t dataType, const uint8
|
||||
} else {
|
||||
sendDataAvail(&pending);
|
||||
}
|
||||
|
||||
wsSendTaginfo(dst, SYNC_TAGSTATUS);
|
||||
}
|
||||
|
||||
@@ -434,7 +435,7 @@ void processXferTimeout(struct espXferComplete* xfc, bool local) {
|
||||
if (local) udpsync.netProcessXferTimeout(xfc);
|
||||
}
|
||||
|
||||
void processDataReq(struct espAvailDataReq* eadr, bool local) {
|
||||
void processDataReq(struct espAvailDataReq* eadr, bool local, IPAddress remoteIP) {
|
||||
if (config.runStatus == RUNSTATUS_STOP) return;
|
||||
char buffer[64];
|
||||
|
||||
@@ -454,13 +455,15 @@ void processDataReq(struct espAvailDataReq* eadr, bool local) {
|
||||
if (!local) {
|
||||
if (taginfo->isExternal == false) {
|
||||
wsLog("moved AP from local to external " + String(hexmac));
|
||||
taginfo->isExternal = true;
|
||||
}
|
||||
taginfo->isExternal = true;
|
||||
taginfo->apIp = remoteIP;
|
||||
} else {
|
||||
if (taginfo->isExternal == true) {
|
||||
wsLog("moved AP from external to local " + String(hexmac));
|
||||
taginfo->isExternal = false;
|
||||
}
|
||||
taginfo->isExternal = false;
|
||||
taginfo->apIp = IPAddress(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
if (taginfo->pendingIdle == 0) {
|
||||
@@ -512,9 +515,11 @@ void processDataReq(struct espAvailDataReq* eadr, bool local) {
|
||||
// sprintf(buffer, "<REMOTE ADR %02X%02X%02X%02X%02X%02X%02X%02X\n\0", eadr->src[7], eadr->src[6], eadr->src[5], eadr->src[4], eadr->src[3], eadr->src[2], eadr->src[1], eadr->src[0]);
|
||||
}
|
||||
|
||||
wsSendTaginfo(eadr->src, SYNC_TAGSTATUS);
|
||||
if (local) {
|
||||
wsSendTaginfo(eadr->src, SYNC_TAGSTATUS);
|
||||
udpsync.netProcessDataReq(eadr);
|
||||
} else {
|
||||
wsSendTaginfo(eadr->src, SYNC_NOSYNC);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -115,6 +115,7 @@ void fillNode(JsonObject& tag, const tagRecord* taginfo) {
|
||||
tag["capabilities"] = taginfo->capabilities;
|
||||
tag["modecfgjson"] = taginfo->modeConfigJson;
|
||||
tag["isexternal"] = taginfo->isExternal;
|
||||
tag["apip"] = taginfo->apIp.toString();
|
||||
tag["rotate"] = taginfo->rotate;
|
||||
tag["lut"] = taginfo->lut;
|
||||
tag["ch"] = taginfo->currentChannel;
|
||||
@@ -122,7 +123,6 @@ void fillNode(JsonObject& tag, const tagRecord* taginfo) {
|
||||
}
|
||||
|
||||
void saveDB(const String& filename) {
|
||||
Serial.println("saveDB start");
|
||||
DynamicJsonDocument doc(2500);
|
||||
|
||||
const long t = millis();
|
||||
@@ -153,7 +153,6 @@ void saveDB(const String& filename) {
|
||||
file.close();
|
||||
xSemaphoreGive(fsMutex);
|
||||
Serial.println("DB saved " + String(millis() - t) + "ms");
|
||||
Serial.println("saveDB end");
|
||||
}
|
||||
|
||||
void loadDB(const String& filename) {
|
||||
@@ -211,6 +210,7 @@ void loadDB(const String& filename) {
|
||||
taginfo->capabilities = tag["capabilities"];
|
||||
taginfo->modeConfigJson = tag["modecfgjson"].as<String>();
|
||||
taginfo->isExternal = tag["isexternal"].as<bool>();
|
||||
taginfo->apIp.fromString(tag["apip"].as<String>());
|
||||
taginfo->rotate = tag["rotate"] | 0;
|
||||
taginfo->lut = tag["lut"] | 0;
|
||||
taginfo->currentChannel = tag["ch"] | 0;
|
||||
|
||||
@@ -50,7 +50,7 @@ void UDPcomm::processPacket(AsyncUDPPacket packet) {
|
||||
espAvailDataReq adr;
|
||||
memset(&adr, 0, sizeof(espAvailDataReq));
|
||||
memcpy(&adr, &packet.data()[1], std::min(packet.length() - 1, sizeof(espAvailDataReq)));
|
||||
processDataReq(&adr, false);
|
||||
processDataReq(&adr, false, senderIP);
|
||||
break;
|
||||
}
|
||||
case PKT_XFER_COMPLETE: {
|
||||
|
||||
@@ -63,47 +63,35 @@ size_t dbSize() {
|
||||
}
|
||||
|
||||
void wsSendSysteminfo() {
|
||||
Serial.println("wsSendSysteminfo begin");
|
||||
DynamicJsonDocument doc(250);
|
||||
JsonObject sys = doc.createNestedObject("sys");
|
||||
time_t now;
|
||||
time(&now);
|
||||
Serial.print("1");
|
||||
static int freeSpaceLastRun = 0;
|
||||
static size_t tagDBsize = 0;
|
||||
static size_t freeSpace = Storage.freeSpace();
|
||||
Serial.print("2");
|
||||
sys["currtime"] = now;
|
||||
Serial.print("3");
|
||||
sys["heap"] = ESP.getFreeHeap();
|
||||
Serial.print("4");
|
||||
sys["recordcount"] = tagDBsize;
|
||||
Serial.print("5");
|
||||
sys["dbsize"] = dbSize();
|
||||
Serial.print("6");
|
||||
if (millis() - freeSpaceLastRun > 30000 || freeSpaceLastRun == 0) {
|
||||
freeSpace = Storage.freeSpace();
|
||||
tagDBsize = tagDB.size();
|
||||
freeSpaceLastRun = millis();
|
||||
}
|
||||
Serial.print("7");
|
||||
sys["littlefsfree"] = freeSpace;
|
||||
sys["apstate"] = apInfo.state;
|
||||
sys["runstate"] = config.runStatus;
|
||||
Serial.print("8");
|
||||
#if !defined(CONFIG_IDF_TARGET_ESP32)
|
||||
// sys["temp"] = temperatureRead();
|
||||
#endif
|
||||
Serial.print("9");
|
||||
sys["rssi"] = WiFi.RSSI();
|
||||
sys["wifistatus"] = WiFi.status();
|
||||
sys["wifissid"] = WiFi.SSID();
|
||||
|
||||
Serial.print("a");
|
||||
setVarDB("ap_ip", WiFi.localIP().toString());
|
||||
setVarDB("ap_ch", String(apInfo.channel));
|
||||
|
||||
Serial.print("b");
|
||||
static uint32_t tagcounttimer = 0;
|
||||
if (millis() - tagcounttimer > 60000 || tagcounttimer == 0) {
|
||||
uint32_t timeoutcount = 0;
|
||||
@@ -117,7 +105,6 @@ void wsSendSysteminfo() {
|
||||
setVarDB("ap_tagcount", result);
|
||||
tagcounttimer = millis();
|
||||
}
|
||||
Serial.println("wsSendSysteminfo end");
|
||||
|
||||
xSemaphoreTake(wsMutex, portMAX_DELAY);
|
||||
ws.textAll(doc.as<String>());
|
||||
@@ -329,6 +316,7 @@ void init_web() {
|
||||
}
|
||||
if (strcmp(cmdValue, "ledflash") == 0) {
|
||||
struct ledFlash flashData = {0};
|
||||
flashData.mode = 1;
|
||||
flashData.flashDuration = 8;
|
||||
flashData.color1 = 0x3C; // green
|
||||
flashData.color2 = 0xE4; // red
|
||||
@@ -345,6 +333,7 @@ void init_web() {
|
||||
}
|
||||
if (strcmp(cmdValue, "ledflash_long") == 0) {
|
||||
struct ledFlash flashData = {0};
|
||||
flashData.mode = 1;
|
||||
flashData.flashDuration = 15;
|
||||
flashData.color1 = 0xE4; // red
|
||||
flashData.flashCount1 = 5;
|
||||
@@ -354,6 +343,12 @@ void init_web() {
|
||||
const uint8_t *payload = reinterpret_cast<const uint8_t *>(&flashData);
|
||||
sendTagCommand(mac, CMD_DO_LEDFLASH, !taginfo->isExternal, payload);
|
||||
}
|
||||
if (strcmp(cmdValue, "ledflash_stop") == 0) {
|
||||
struct ledFlash flashData = {0};
|
||||
flashData.mode = 0;
|
||||
const uint8_t *payload = reinterpret_cast<const uint8_t *>(&flashData);
|
||||
sendTagCommand(mac, CMD_DO_LEDFLASH, !taginfo->isExternal, payload);
|
||||
}
|
||||
request->send(200, "text/plain", "Ok, done");
|
||||
} else {
|
||||
request->send(400, "text/plain", "Error: mac not found");
|
||||
@@ -367,6 +362,7 @@ void init_web() {
|
||||
server.on("/led_flash", HTTP_GET, [](AsyncWebServerRequest *request) {
|
||||
// color picker: https://roger-random.github.io/RGB332_color_wheel_three.js/
|
||||
// http GET to /led_flash?mac=000000000000&pattern=3/0x1C,4,5/0xE0,3,1/0x4F,5,10/5
|
||||
// http://192.168.178.198/led_flash?mac=00007E1F250CB29C&pattern=1/0x1C,1,15/0xE0,1,15/0x4F,1,15/1
|
||||
// (flashDuration/color1,flashCount1,delay1/color2,flashCount2,delay2/color3,flashCount3,delay3/repeats)
|
||||
if (request->hasParam("mac")) {
|
||||
String dst = request->getParam("mac")->value();
|
||||
@@ -604,6 +600,9 @@ void init_web() {
|
||||
request->send(404);
|
||||
});
|
||||
|
||||
DefaultHeaders::Instance().addHeader("Access-Control-Allow-Origin", "*");
|
||||
DefaultHeaders::Instance().addHeader("Access-Control-Allow-Headers", "content-type");
|
||||
|
||||
server.begin();
|
||||
}
|
||||
|
||||
|
||||
@@ -215,7 +215,6 @@ void WifiManager::pollSerial() {
|
||||
}
|
||||
}
|
||||
|
||||
// temporary write some more debug info
|
||||
void WifiManager::WiFiEvent(WiFiEvent_t event) {
|
||||
Serial.printf("[WiFi-event %d] ", event);
|
||||
String eventname="";
|
||||
@@ -259,8 +258,8 @@ void WifiManager::WiFiEvent(WiFiEvent_t event) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
terminalLog(eventname);
|
||||
logLine("WiFi event [" + String(event) + "]: " + eventname);
|
||||
if (eventname) terminalLog(eventname);
|
||||
// logLine("WiFi event [" + String(event) + "]: " + eventname);
|
||||
}
|
||||
|
||||
// *** Improv
|
||||
|
||||
@@ -12,6 +12,7 @@ const WAKEUP_REASON_WDT_RESET = 0xFE;
|
||||
|
||||
let tagTypes = {};
|
||||
let apConfig = {};
|
||||
let tagDB = {};
|
||||
|
||||
const apstate = [
|
||||
{ state: "offline", color: "red" },
|
||||
@@ -93,7 +94,7 @@ function connect() {
|
||||
});
|
||||
|
||||
socket.addEventListener("message", (event) => {
|
||||
// console.log(event.data)
|
||||
console.log(event.data)
|
||||
const msg = JSON.parse(event.data);
|
||||
if (msg.logMsg) {
|
||||
showMessage(msg.logMsg, false);
|
||||
@@ -156,6 +157,7 @@ function convertSize(bytes) {
|
||||
function processTags(tagArray) {
|
||||
for (const element of tagArray) {
|
||||
const tagmac = element.mac;
|
||||
tagDB[tagmac] = element;
|
||||
|
||||
let div = $('#tag' + tagmac);
|
||||
if (div == null) {
|
||||
@@ -217,10 +219,16 @@ function processTags(tagArray) {
|
||||
$('#tag' + tagmac + ' .received').style.opacity = "0";
|
||||
}
|
||||
|
||||
if (!apConfig.preview || element.contentMode == 20 || (element.isexternal && element.contentMode == 12)) {
|
||||
if (!apConfig.preview || element.contentMode == 20) {
|
||||
$('#tag' + tagmac + ' .tagimg').style.display = 'none'
|
||||
} else if (div.dataset.hash != element.hash && div.dataset.hwtype > -1 && (!element.isexternal || element.contentMode != 12)) {
|
||||
loadImage(tagmac, '/current/' + tagmac + '.raw?' + element.hash);
|
||||
} else if (div.dataset.hash != element.hash && div.dataset.hwtype > -1) {
|
||||
let cachetag = element.hash;
|
||||
if (element.hash == '00000000000000000000000000000000') cachetag = Math.random();
|
||||
if (element.isexternal && element.contentMode == 12) {
|
||||
loadImage(tagmac, 'http://' + tagDB[tagmac].apip + '/current/' + tagmac + '.raw?' + cachetag);
|
||||
} else {
|
||||
loadImage(tagmac, '/current/' + tagmac + '.raw?' + cachetag);
|
||||
}
|
||||
div.dataset.hash = element.hash;
|
||||
}
|
||||
|
||||
@@ -1108,7 +1116,8 @@ $('#taglist').addEventListener('contextmenu', (e) => {
|
||||
if (tagTypes[hwtype].options?.includes("led")) {
|
||||
contextMenuOptions.push(
|
||||
{ id: 'ledflash', label: 'Flash the LED' },
|
||||
{ id: 'ledflash_long', label: 'Flash the LED (long)' }
|
||||
{ id: 'ledflash_long', label: 'Flash the LED (long)' },
|
||||
{ id: 'ledflash_stop', label: 'Stop flashing' }
|
||||
);
|
||||
}
|
||||
contextMenuOptions.push(
|
||||
|
||||
@@ -174,13 +174,16 @@ struct ledFlash {
|
||||
uint8_t flashDuration : 4;
|
||||
uint8_t color1;
|
||||
uint8_t flashCount1 : 4;
|
||||
uint8_t delay1 : 4;
|
||||
uint8_t flashSpeed1 : 4;
|
||||
uint8_t delay1;
|
||||
uint8_t color2;
|
||||
uint8_t flashCount2 : 4;
|
||||
uint8_t delay2 : 4;
|
||||
uint8_t flashSpeed2 : 4;
|
||||
uint8_t delay2;
|
||||
uint8_t color3;
|
||||
uint8_t flashCount3 : 4;
|
||||
uint8_t delay3 : 4;
|
||||
uint8_t flashSpeed3 : 4;
|
||||
uint8_t delay3;
|
||||
uint8_t repeats;
|
||||
uint8_t spare;
|
||||
} __packed;
|
||||
|
||||
Reference in New Issue
Block a user