Added 'Set Mac' datatype/content card

This commit is contained in:
Jelmer
2024-12-15 23:11:19 +01:00
parent e246ac578d
commit 375662c69e
4 changed files with 51 additions and 0 deletions

View File

@@ -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);

View File

@@ -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<String>().c_str(), "%llx", &newmac);
sendTagMac(mac, newmac, (taginfo->isExternal == false));
taginfo->nextupdate = 3216153600;
break;
}
}
taginfo->modeConfigJson = doc.as<String>();

View File

@@ -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);

View File

@@ -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",