diff --git a/data/example.config.json b/data/example.config.json index f7ae25e..2ab36dc 100644 --- a/data/example.config.json +++ b/data/example.config.json @@ -1,10 +1,10 @@ { "stationMode": 0, - "channel": 11, - "meshPort": 5555, - "meshSSID": "illucat-mesh", + "hostname": "illucat", + "stationSSID": "MyWifi", + "stationPassword": "myWifiPassword", + "meshSSID": "illucat", "meshPassword": "th3r31sn0sp00n", - "stationSSID": "MyAP", - "stationPassword": "th3r31sn0sp00n", - "hostname": "illucat" + "meshPort": 5555, + "channel": 11 } \ No newline at end of file diff --git a/data/www/styles.css b/data/www/styles.css index 29fca97..403b7a9 100644 --- a/data/www/styles.css +++ b/data/www/styles.css @@ -10,7 +10,7 @@ .sui { background: #000000; color: #0eb8c0; - font-family: "Open Sans"; + font-family: Tahoma, Geneva, sans-serif; font-size: 16px; } .sui * { diff --git a/src/IlluCat.h b/src/IlluCat.h index 360b37c..20b2724 100644 --- a/src/IlluCat.h +++ b/src/IlluCat.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "config.h" @@ -22,6 +23,7 @@ using namespace std; using namespace std::placeholders; +const byte DNS_PORT = 53; class IlluCat : public MeshSprocket { public: @@ -30,6 +32,7 @@ class IlluCat : public MeshSprocket { NeoPatternDto state; AsyncWebServer* server; AsyncWebSocket* ws; + DNSServer* dnsServer; NeoPixelConfig pixelConfig; SprocketConfig sprocketConfig; @@ -76,12 +79,17 @@ class IlluCat : public MeshSprocket { pixels = new NeoPattern(pixelConfig.length, pixelConfig.pin, NEO_GRB + NEO_KHZ800); server = new AsyncWebServer(80); ws = new AsyncWebSocket("/pixel"); + dnsServer = new DNSServer(); addPlugin(new OtaTcpPlugin(otaConfig)); addPlugin(new WebServerPlugin(webConfig, server)); addPlugin(new WebConfigPlugin(server)); addPlugin(new PixelPlugin(pixelConfig, pixels)); + + dnsServer->setErrorReplyCode(DNSReplyCode::NoError); + dnsServer->start(DNS_PORT, "*", WiFi.softAPIP()); + Serial.println(WiFi.softAPIP()); defaultAnimation(); // setup web stuff @@ -98,8 +106,8 @@ class IlluCat : public MeshSprocket { void patternWebRequestHandler(AsyncWebServerRequest *request) { Serial.println("POST /pixel/state"); - if(request->hasParam("msg", true)) { - String inStr = request->getParam("msg", true)->value(); + if(request->hasParam("state", true)) { + String inStr = request->getParam("state", true)->value(); dispatch(0, inStr); } 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) { if(type == WS_EVT_DATA){ String frame = WsUtils::parseFrameAsString(type, arg, data, len, 0); - dispatch(0, frame); - // TODO broadcast enable/disable flag net->mesh.sendBroadcast(frame); + dispatch(0, frame); client->text(String(millis())); } } @@ -126,7 +133,7 @@ class IlluCat : public MeshSprocket { virtual void onNewConnection(uint32_t nodeId){ PRINT_MSG(Serial, SPROCKET_TYPE, "connected to %u", nodeId); // publish current state to new node - // FIXME we got a memory leak here + // TODO broadcast enable/disable flag //String stateJson = currentMessage.toJsonString(); //net->mesh.sendSingle(nodeId, stateJson); } @@ -139,6 +146,7 @@ class IlluCat : public MeshSprocket { void loop(){ MeshSprocket::loop(); + dnsServer->processNextRequest(); } };