mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 04:06:29 +01:00
simple http call to test the led flasher
This commit is contained in:
@@ -126,4 +126,20 @@ struct tagsettings {
|
||||
uint8_t fixedChannel; // default 0; if set to a valid channel number, the tag will stick to that channel
|
||||
} __packed;
|
||||
|
||||
struct ledFlash {
|
||||
uint8_t mode : 4;
|
||||
uint8_t flashDuration : 4;
|
||||
uint8_t color1;
|
||||
uint8_t flashCount1 : 4;
|
||||
uint8_t delay1 : 4;
|
||||
uint8_t color2;
|
||||
uint8_t flashCount2 : 4;
|
||||
uint8_t delay2 : 4;
|
||||
uint8_t color3;
|
||||
uint8_t flashCount3 : 4;
|
||||
uint8_t delay3 : 4;
|
||||
uint8_t repeats;
|
||||
uint8_t spare;
|
||||
} __packed;
|
||||
|
||||
#pragma pack(pop)
|
||||
@@ -320,9 +320,11 @@ void init_web() {
|
||||
if (strcmp(cmdValue, "deepsleep") == 0) {
|
||||
sendTagCommand(mac, CMD_DO_DEEPSLEEP, !taginfo->isExternal);
|
||||
}
|
||||
if (strcmp(cmdValue, "ledflash") == 0) {
|
||||
}
|
||||
request->send(200, "text/plain", "Ok, done");
|
||||
} else {
|
||||
request->send(200, "text/plain", "Error: mac not found");
|
||||
request->send(400, "text/plain", "Error: mac not found");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -330,6 +332,55 @@ 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
|
||||
// (flashDuration/color1,flashCount1,delay1/color2,flashCount2,delay2/color3,flashCount3,delay3/repeats)
|
||||
if (request->hasParam("mac")) {
|
||||
String dst = request->getParam("mac")->value();
|
||||
uint8_t mac[8];
|
||||
if (hex2mac(dst, mac)) {
|
||||
tagRecord *taginfo = tagRecord::findByMAC(mac);
|
||||
if (taginfo != nullptr) {
|
||||
if (request->hasParam("pattern")) {
|
||||
String pattern = request->getParam("pattern")->value();
|
||||
struct ledFlash flashData;
|
||||
|
||||
int values[13];
|
||||
int numValues = sscanf(
|
||||
pattern.c_str(),
|
||||
"%i/%i,%i,%i/%i,%i,%i/%i,%i,%i/%i",
|
||||
&values[1], &values[2], &values[3], &values[4], &values[5],
|
||||
&values[6], &values[7], &values[8], &values[9], &values[10], &values[11]);
|
||||
|
||||
if (numValues != 11) {
|
||||
request->send(400, "text/plain", "Error: wrong number of inputs in pattern");
|
||||
return;
|
||||
} else {
|
||||
flashData.mode = 0;
|
||||
flashData.flashDuration = values[1] & 0x0F;
|
||||
flashData.color1 = values[2];
|
||||
flashData.flashCount1 = values[3] & 0x0F;
|
||||
flashData.delay1 = values[4] & 0x0F;
|
||||
flashData.color2 = values[5];
|
||||
flashData.flashCount2 = values[6] & 0x0F;
|
||||
flashData.delay2 = values[7] & 0x0F;
|
||||
flashData.color3 = values[8];
|
||||
flashData.flashCount3 = values[9] & 0x0F;
|
||||
flashData.delay3 = values[10] & 0x0F;
|
||||
flashData.repeats = values[11];
|
||||
flashData.spare = 0;
|
||||
|
||||
const uint8_t *payload = reinterpret_cast<const uint8_t *>(&flashData);
|
||||
sendTagCommand(mac, CMD_DO_LEDFLASH, !taginfo->isExternal, payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
request->send(400, "text/plain", "parameters are missing");
|
||||
});
|
||||
|
||||
server.on("/get_ap_config", HTTP_GET, [](AsyncWebServerRequest *request) {
|
||||
UDPcomm udpsync;
|
||||
udpsync.getAPList();
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#define CMD_DO_SCAN 1
|
||||
#define CMD_DO_RESET_SETTINGS 2
|
||||
#define CMD_DO_DEEPSLEEP 3
|
||||
#define CMD_DO_LEDFLASH 4
|
||||
|
||||
#define WAKEUP_REASON_TIMED 0
|
||||
#define WAKEUP_REASON_GPIO 2
|
||||
|
||||
Reference in New Issue
Block a user