Skip to content

Веб-морда для лампы#7

Open
CoOre wants to merge 3 commits into
AlexGyver:masterfrom
CoOre:master
Open

Веб-морда для лампы#7
CoOre wants to merge 3 commits into
AlexGyver:masterfrom
CoOre:master

Conversation

@CoOre

@CoOre CoOre commented Jul 20, 2019

Copy link
Copy Markdown

Работает на порте 8080
Сильно не пинайте, опыт на C++ минимальный

* шаблон/отправщик страницы
*/
void responseHtml(String out, String title = "AlexGyver Lamp", int code = 200){
String html;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не очень удобно читать, да и поддерживать, думаю. Может, можно в файл вынести и сюда как-то при сборке подставлять?

out += "\"on\":\"" + String(ONflag) + "\"";
out += "}";

http.send(200, "text/json", out);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
http.send(200, "text/json", out);
http.send(200, "application/json", out);

Comment on lines +160 to +166
out += "{";
out += "\"currentMode\":\"" + String(currentMode) + "\",";
out += "\"brightness\":\"" + String(modes[currentMode].brightness) + "\",";
out += "\"speed\":\"" + String(modes[currentMode].speed) + "\",";
out += "\"scale\":\"" + String(modes[currentMode].scale) + "\",";
out += "\"on\":\"" + String(ONflag) + "\"";
out += "}";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Думаю, стоит использовать библиотеку для сериализации, например, вот эту

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants