optimize printing, add release profile

This commit is contained in:
2018-09-24 12:10:09 +02:00
parent 4c49d2660e
commit 88558532ee
6 changed files with 76 additions and 24 deletions

View File

@@ -90,9 +90,10 @@ class IlluCat : public MeshSprocket {
// plugin?
dnsServer->setErrorReplyCode(DNSReplyCode::NoError);
dnsServer->start(DNS_PORT, "*", WiFi.softAPIP());
Serial.println("SoftAP IP: " + WiFi.softAPIP().toString());
String softApPrt = "SoftAP IP: " + WiFi.softAPIP().toString();
PRINT_MSG(Serial, SPROCKET_TYPE, softApPrt.c_str());
// TODO plugin
// 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));
@@ -111,30 +112,33 @@ class IlluCat : public MeshSprocket {
}
void patternWebRequestHandler(AsyncWebServerRequest *request) {
Serial.println("POST /pixel/state");
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();
net->mesh.sendBroadcast(msg);
publish(currentMessage.topic, currentMessage.payload);
if(currentMessage.broadcast){
net->mesh.sendBroadcast(msg);
}
request->send(200, "text/plain", msg);
}
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);
net->mesh.sendBroadcast(frame);
dispatch(0, frame);
//client->text(String(millis()));
}
}
virtual void dispatch( uint32_t from, String &msg ) {
//Serial.println(msg);
currentMessage.fromJsonString(msg);
if(currentMessage.valid){
currentMessage.from = from;
publish(currentMessage.topic, currentMessage.payload);
if(currentMessage.broadcast){
net->mesh.sendBroadcast(msg);
}
}
}