remove unused

This commit is contained in:
2018-11-05 16:19:19 +01:00
parent a940903bd3
commit a039e591da
2 changed files with 9 additions and 121 deletions

View File

@@ -2,125 +2,17 @@
IlluCat::IlluCat(SprocketConfig cfg, OtaConfig otaCfg, WebServerConfig webCfg) : Sprocket(cfg)
{
Serial.println("illucat ctr");
sprocketConfig = cfg;
otaConfig = otaCfg;
webConfig = webCfg;
pixelConfig.pin = 4;
pixelConfig.length = 8;
pixelConfig.brightness = 32;
pixelConfig.updateInterval = 100;
pixelConfig.defaultColor = 100;
catScheduler = new Scheduler();
}
void IlluCat::scanningAnimation()
{
pixels->Scanner(pixels->Wheel(COLOR_NOT_CONNECTED), pixelConfig.updateInterval);
}
void IlluCat::defaultAnimation()
{
pixels->RainbowCycle(pixelConfig.updateInterval);
}
/* Sprocket *IlluCat::activate(Scheduler *scheduler, Network *network)
{
// load config files from SPIFFS
if (SPIFFS.begin())
{
pixelConfig.fromFile("/pixelConfig.json");
defaultState.fromFile("/pixelState.json");
state = defaultState;
}
// initialize services
pixels = new NeoPattern(pixelConfig.length, pixelConfig.pin, NEO_GRB + NEO_KHZ800);
server = new AsyncWebServer(80);
ws = new AsyncWebSocket("/pixel");
//wsStream = new AsyncWebSocket("/stream");
defaultAnimation();
server->serveStatic(PIXEL_CONFIG_FILE, SPIFFS, "pixelConfig.json");
}
// add plugins
// TODO add HTTP OTA instead of TCP
//addPlugin(new OtaTcpPlugin(otaConfig));
void IlluCat::setup()
{
addPlugin(new PixelPlugin());
addPlugin(new WebServerPlugin(webConfig, server));
addPlugin(new WebConfigPlugin(server));
addPlugin(new PixelPlugin(pixelConfig, pixels));
// FIXME move to networking
//String softApPrt = "SoftAP IP: " + WiFi.softAPIP().toString();
//PRINT_MSG(Serial, SPROCKET_TYPE, softApPrt.c_str());
// TODO move to plugin
// setup web stuff
server->serveStatic("/pixelConfig.json", SPIFFS, "pixelConfig.json");
server->on("/pixel/api", HTTP_POST, bind(&IlluCat::patternWebRequestHandler, this, _1));
ws->onEvent(bind(&IlluCat::onWsEvent, this, _1, _2, _3, _4, _5, _6));
server->addHandler(ws);
//wsStream->onEvent(bind(&IlluCat::onStream, this, _1, _2, _3, _4, _5, _6));
//server->addHandler(wsStream);
return Sprocket::activate(scheduler, network);
} using Sprocket::activate; */
// TODO move to utils
/* String IlluCat::getRequestParameterOrDefault(AsyncWebServerRequest *request, String param, String defaultValue, bool isPost)
{
if (request->hasParam(param, isPost))
{
return request->getParam(param, isPost)->value();
}
return defaultValue;
}
void IlluCat::onStream(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len)
{
if (type == WS_EVT_DATA)
{
PRINT_MSG(Serial, SPROCKET_TYPE, WebUtils::parseFrameAsString(type, arg, data, len, 0).c_str());
pixels->ActivePattern = NONE;
pixels->handleStream(data, len);
}
}
void IlluCat::patternWebRequestHandler(AsyncWebServerRequest *request)
{
PRINT_MSG(Serial, SPROCKET_TYPE, "POST /pixel/api");
currentMessage.topic = getRequestParameterOrDefault(request, "topic", "");
currentMessage.payload = getRequestParameterOrDefault(request, "payload", "");
currentMessage.broadcast = atoi(getRequestParameterOrDefault(request, "broadcast", "0").c_str());
String msg = currentMessage.toJsonString();
publish(currentMessage.topic, currentMessage.payload);
if (currentMessage.broadcast)
{
network.broadcast(msg);
}
request->send(200, "text/plain", msg);
}
void IlluCat::onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len)
{
if (type == WS_EVT_DATA)
{
String frame = WebUtils::parseFrameAsString(type, arg, data, len, 0);
dispatch(0, frame);
network.broadcast(frame);
}
}
void IlluCat::dispatch(uint32_t from, String &msg)
{
currentMessage.fromJsonString(msg);
if (currentMessage.valid)
{
currentMessage.from = from;
publish(currentMessage.topic, currentMessage.payload);
}
}
void IlluCat::loop()
{
Sprocket::loop();
yield();
} */
addPlugin(new WebApi(server, 1));
}

View File

@@ -1,5 +1,5 @@
#ifndef __MESH_APP__
#define __MESH_APP__
#ifndef __ILLUCAT__
#define __ILLUCAT__
#include <TaskScheduler.h>
#include <MeshNet.h>
@@ -8,10 +8,6 @@
#include "config.h"
#include "NeoPattern.cpp"
#include "NeoPatternDto.h"
#include "NeoPattern_api_json.h"
#include "NeoPattern_api_modes.cpp"
#include "utils_print.h"
#include "utils_web.h"
#include <plugins/WebSO.h>
#include <plugins/OtaTcpPlugin.cpp>
#include <plugins/WebServerPlugin.cpp>