diff --git a/ESP32_AP-Flasher/include/newproto.h b/ESP32_AP-Flasher/include/newproto.h index bdb71e04..23e345bd 100644 --- a/ESP32_AP-Flasher/include/newproto.h +++ b/ESP32_AP-Flasher/include/newproto.h @@ -26,6 +26,7 @@ extern void processDataReq(struct espAvailDataReq* adr, bool local, IPAddress re 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); +bool sendTagMac(const uint8_t* dst, const uint64_t newmac, 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, IPAddress remoteIP); diff --git a/ESP32_AP-Flasher/src/contentmanager.cpp b/ESP32_AP-Flasher/src/contentmanager.cpp index bbf6b976..d1622d43 100644 --- a/ESP32_AP-Flasher/src/contentmanager.cpp +++ b/ESP32_AP-Flasher/src/contentmanager.cpp @@ -551,6 +551,14 @@ void drawNew(const uint8_t mac[8], tagRecord *&taginfo) { } break; #endif + case 28: // tag command + { + uint64_t newmac; + sscanf(cfgobj["mac"].as().c_str(), "%llx", &newmac); + sendTagMac(mac, newmac, (taginfo->isExternal == false)); + taginfo->nextupdate = 3216153600; + break; + } } taginfo->modeConfigJson = doc.as(); diff --git a/ESP32_AP-Flasher/src/newproto.cpp b/ESP32_AP-Flasher/src/newproto.cpp index c8131b60..5f8d722b 100644 --- a/ESP32_AP-Flasher/src/newproto.cpp +++ b/ESP32_AP-Flasher/src/newproto.cpp @@ -752,6 +752,35 @@ bool sendTagCommand(const uint8_t* dst, uint8_t cmd, bool local, const uint8_t* } } +bool sendTagMac(const uint8_t* dst, const uint64_t newmac, bool local) { + struct pendingData pending = {0}; + memcpy(pending.targetMac, dst, 8); + pending.availdatainfo.dataType = DATATYPE_COMMAND_DATA; + pending.availdatainfo.dataTypeArgument = 0x23; + pending.availdatainfo.nextCheckIn = 0; + + + pending.availdatainfo.dataVer = newmac; + pending.availdatainfo.dataSize = 0; + + pending.attemptsLeft = MAX_XFER_ATTEMPTS; + Serial.printf(">Tag %02X%02X%02X%02X%02X%02X%02X%02X Mac set\r\n\0", dst[7], dst[6], dst[5], dst[4], dst[3], dst[2], dst[1], dst[0]); + + tagRecord* taginfo = tagRecord::findByMAC(dst); + if (taginfo != nullptr) { + taginfo->pendingCount++; + wsSendTaginfo(taginfo->mac, SYNC_TAGSTATUS); + } + + if (local) { + return queueDataAvail(&pending, true); + } else { + queueDataAvail(&pending, false); + udpsync.netSendDataAvail(&pending); + return true; + } +} + void updateTaginfoitem(struct TagInfo* taginfoitem, IPAddress remoteIP) { tagRecord* taginfo = tagRecord::findByMAC(taginfoitem->mac); diff --git a/ESP32_AP-Flasher/wwwroot/content_cards.json b/ESP32_AP-Flasher/wwwroot/content_cards.json index c44262b4..f75cc5f7 100644 --- a/ESP32_AP-Flasher/wwwroot/content_cards.json +++ b/ESP32_AP-Flasher/wwwroot/content_cards.json @@ -606,6 +606,19 @@ } ] }, + { + "id": 28, + "name": "Set Tag Mac", + "desc": "Sets the tags mac-address to a specific value. Must be 16 characters, hexdecimal (8 bytes)", + "param": [ + { + "key": "mac", + "name": "MAC", + "desc": "Set Mac address", + "type": "text" + } + ] + }, { "id": 18, "name": "Set Tag Config",