mirror of
https://gitlab.com/zwirbel/illucat.git
synced 2025-12-16 18:05:05 +01:00
updated font, change order of config attributes
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"stationMode": 0,
|
"stationMode": 0,
|
||||||
"channel": 11,
|
"hostname": "illucat",
|
||||||
"meshPort": 5555,
|
"stationSSID": "MyWifi",
|
||||||
"meshSSID": "illucat-mesh",
|
"stationPassword": "myWifiPassword",
|
||||||
|
"meshSSID": "illucat",
|
||||||
"meshPassword": "th3r31sn0sp00n",
|
"meshPassword": "th3r31sn0sp00n",
|
||||||
"stationSSID": "MyAP",
|
"meshPort": 5555,
|
||||||
"stationPassword": "th3r31sn0sp00n",
|
"channel": 11
|
||||||
"hostname": "illucat"
|
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
.sui {
|
.sui {
|
||||||
background: #000000;
|
background: #000000;
|
||||||
color: #0eb8c0;
|
color: #0eb8c0;
|
||||||
font-family: "Open Sans";
|
font-family: Tahoma, Geneva, sans-serif;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
.sui * {
|
.sui * {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <painlessMesh.h>
|
#include <painlessMesh.h>
|
||||||
#include <base/MeshSprocket.h>
|
#include <base/MeshSprocket.h>
|
||||||
#include <MeshNet.h>
|
#include <MeshNet.h>
|
||||||
|
#include <DNSServer.h>
|
||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@@ -22,6 +23,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
|
|
||||||
|
const byte DNS_PORT = 53;
|
||||||
|
|
||||||
class IlluCat : public MeshSprocket {
|
class IlluCat : public MeshSprocket {
|
||||||
public:
|
public:
|
||||||
@@ -30,6 +32,7 @@ class IlluCat : public MeshSprocket {
|
|||||||
NeoPatternDto state;
|
NeoPatternDto state;
|
||||||
AsyncWebServer* server;
|
AsyncWebServer* server;
|
||||||
AsyncWebSocket* ws;
|
AsyncWebSocket* ws;
|
||||||
|
DNSServer* dnsServer;
|
||||||
|
|
||||||
NeoPixelConfig pixelConfig;
|
NeoPixelConfig pixelConfig;
|
||||||
SprocketConfig sprocketConfig;
|
SprocketConfig sprocketConfig;
|
||||||
@@ -76,12 +79,17 @@ class IlluCat : public MeshSprocket {
|
|||||||
pixels = new NeoPattern(pixelConfig.length, pixelConfig.pin, NEO_GRB + NEO_KHZ800);
|
pixels = new NeoPattern(pixelConfig.length, pixelConfig.pin, NEO_GRB + NEO_KHZ800);
|
||||||
server = new AsyncWebServer(80);
|
server = new AsyncWebServer(80);
|
||||||
ws = new AsyncWebSocket("/pixel");
|
ws = new AsyncWebSocket("/pixel");
|
||||||
|
dnsServer = new DNSServer();
|
||||||
|
|
||||||
addPlugin(new OtaTcpPlugin(otaConfig));
|
addPlugin(new OtaTcpPlugin(otaConfig));
|
||||||
addPlugin(new WebServerPlugin(webConfig, server));
|
addPlugin(new WebServerPlugin(webConfig, server));
|
||||||
addPlugin(new WebConfigPlugin(server));
|
addPlugin(new WebConfigPlugin(server));
|
||||||
addPlugin(new PixelPlugin(pixelConfig, pixels));
|
addPlugin(new PixelPlugin(pixelConfig, pixels));
|
||||||
|
|
||||||
|
|
||||||
|
dnsServer->setErrorReplyCode(DNSReplyCode::NoError);
|
||||||
|
dnsServer->start(DNS_PORT, "*", WiFi.softAPIP());
|
||||||
|
Serial.println(WiFi.softAPIP());
|
||||||
defaultAnimation();
|
defaultAnimation();
|
||||||
|
|
||||||
// setup web stuff
|
// setup web stuff
|
||||||
@@ -98,8 +106,8 @@ class IlluCat : public MeshSprocket {
|
|||||||
|
|
||||||
void patternWebRequestHandler(AsyncWebServerRequest *request) {
|
void patternWebRequestHandler(AsyncWebServerRequest *request) {
|
||||||
Serial.println("POST /pixel/state");
|
Serial.println("POST /pixel/state");
|
||||||
if(request->hasParam("msg", true)) {
|
if(request->hasParam("state", true)) {
|
||||||
String inStr = request->getParam("msg", true)->value();
|
String inStr = request->getParam("state", true)->value();
|
||||||
dispatch(0, inStr);
|
dispatch(0, inStr);
|
||||||
}
|
}
|
||||||
request->send(200, "text/plain", "OK");
|
request->send(200, "text/plain", "OK");
|
||||||
@@ -108,9 +116,8 @@ class IlluCat : public MeshSprocket {
|
|||||||
virtual void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len) {
|
virtual void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len) {
|
||||||
if(type == WS_EVT_DATA){
|
if(type == WS_EVT_DATA){
|
||||||
String frame = WsUtils::parseFrameAsString(type, arg, data, len, 0);
|
String frame = WsUtils::parseFrameAsString(type, arg, data, len, 0);
|
||||||
dispatch(0, frame);
|
|
||||||
// TODO broadcast enable/disable flag
|
|
||||||
net->mesh.sendBroadcast(frame);
|
net->mesh.sendBroadcast(frame);
|
||||||
|
dispatch(0, frame);
|
||||||
client->text(String(millis()));
|
client->text(String(millis()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,7 +133,7 @@ class IlluCat : public MeshSprocket {
|
|||||||
virtual void onNewConnection(uint32_t nodeId){
|
virtual void onNewConnection(uint32_t nodeId){
|
||||||
PRINT_MSG(Serial, SPROCKET_TYPE, "connected to %u", nodeId);
|
PRINT_MSG(Serial, SPROCKET_TYPE, "connected to %u", nodeId);
|
||||||
// publish current state to new node
|
// publish current state to new node
|
||||||
// FIXME we got a memory leak here
|
// TODO broadcast enable/disable flag
|
||||||
//String stateJson = currentMessage.toJsonString();
|
//String stateJson = currentMessage.toJsonString();
|
||||||
//net->mesh.sendSingle(nodeId, stateJson);
|
//net->mesh.sendSingle(nodeId, stateJson);
|
||||||
}
|
}
|
||||||
@@ -139,6 +146,7 @@ class IlluCat : public MeshSprocket {
|
|||||||
|
|
||||||
void loop(){
|
void loop(){
|
||||||
MeshSprocket::loop();
|
MeshSprocket::loop();
|
||||||
|
dnsServer->processNextRequest();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user