mirror of
https://gitlab.com/zwirbel/illucat.git
synced 2025-12-15 01:42:22 +01:00
Merge branch 'standalone' into release/1.0.0
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"stationMode": 0,
|
||||
"hostname": "illucat",
|
||||
"apSSID": "illucat",
|
||||
"apPassword": "illucat",
|
||||
"stationSSID": "MyWifi",
|
||||
"stationPassword": "myWifiPassword",
|
||||
"meshSSID": "illucat",
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#ifndef __MESH_APP__
|
||||
#define __MESH_APP__
|
||||
|
||||
#include <painlessMesh.h>
|
||||
#include <base/MeshSprocket.h>
|
||||
#include <MeshNet.h>
|
||||
#include <TaskScheduler.h>
|
||||
//#include <painlessMesh.h>
|
||||
//#include <MeshNet.h>
|
||||
#include <Sprocket.h>
|
||||
//#include <DNSServer.h>
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include "NeoPattern.cpp"
|
||||
@@ -21,8 +24,11 @@
|
||||
using namespace std;
|
||||
using namespace std::placeholders;
|
||||
|
||||
class IlluCat : public MeshSprocket {
|
||||
//const byte DNS_PORT = 53;
|
||||
|
||||
class IlluCat : public Sprocket {
|
||||
public:
|
||||
Scheduler* ts;
|
||||
NeoPattern* pixels;
|
||||
NeoPatternDto defaultState;
|
||||
NeoPatternDto state;
|
||||
@@ -37,7 +43,7 @@ class IlluCat : public MeshSprocket {
|
||||
|
||||
SprocketMessage currentMessage;
|
||||
|
||||
IlluCat(SprocketConfig cfg, OtaConfig otaCfg, WebServerConfig webCfg/* , NeoPixelConfig pixelCfg */) : MeshSprocket(cfg) {
|
||||
IlluCat(SprocketConfig cfg, OtaConfig otaCfg, WebServerConfig webCfg/* , NeoPixelConfig pixelCfg */) : Sprocket(cfg) {
|
||||
//pixelConfig = pixelCfg;
|
||||
|
||||
sprocketConfig = cfg;
|
||||
@@ -49,6 +55,8 @@ class IlluCat : public MeshSprocket {
|
||||
pixelConfig.brightness = 32;
|
||||
pixelConfig.updateInterval = 100;
|
||||
pixelConfig.defaultColor = 100;
|
||||
|
||||
ts = new Scheduler();
|
||||
|
||||
}
|
||||
virtual void scanningAnimation() {
|
||||
@@ -60,7 +68,7 @@ class IlluCat : public MeshSprocket {
|
||||
}
|
||||
Sprocket* activate(Scheduler* scheduler, Network* network) {
|
||||
|
||||
net = static_cast<MeshNet*>(network);
|
||||
//net = static_cast<MeshNet*>(network);
|
||||
|
||||
// load config files from SPIFFS
|
||||
if(SPIFFS.begin()){
|
||||
@@ -76,12 +84,16 @@ class IlluCat : public MeshSprocket {
|
||||
wsStream = new AsyncWebSocket("/stream");
|
||||
|
||||
// add plugins
|
||||
addPlugin(new OtaTcpPlugin(otaConfig));
|
||||
//addPlugin(new OtaTcpPlugin(otaConfig));
|
||||
addPlugin(new WebServerPlugin(webConfig, server));
|
||||
addPlugin(new WebConfigPlugin(server));
|
||||
addPlugin(new PixelPlugin(pixelConfig, pixels));
|
||||
defaultAnimation();
|
||||
|
||||
// configure DNS
|
||||
// plugin?
|
||||
//dnsServer->setErrorReplyCode(DNSReplyCode::NoError);
|
||||
//dnsServer->start(DNS_PORT, "*", WiFi.softAPIP());
|
||||
String softApPrt = "SoftAP IP: " + WiFi.softAPIP().toString();
|
||||
PRINT_MSG(Serial, SPROCKET_TYPE, softApPrt.c_str());
|
||||
|
||||
@@ -94,8 +106,8 @@ class IlluCat : public MeshSprocket {
|
||||
wsStream->onEvent(bind(&IlluCat::onStream, this, _1, _2, _3, _4, _5, _6));
|
||||
server->addHandler(wsStream);
|
||||
|
||||
return MeshSprocket::activate(scheduler, network);
|
||||
} using MeshSprocket::activate;
|
||||
return Sprocket::activate(scheduler, network);
|
||||
} using Sprocket::activate;
|
||||
|
||||
// TODO move to utils
|
||||
String getRequestParameterOrDefault(AsyncWebServerRequest *request, String param, String defaultValue, bool isPost = true){
|
||||
@@ -122,7 +134,7 @@ class IlluCat : public MeshSprocket {
|
||||
String msg = currentMessage.toJsonString();
|
||||
publish(currentMessage.topic, currentMessage.payload);
|
||||
if(currentMessage.broadcast){
|
||||
net->mesh.sendBroadcast(msg);
|
||||
network.broadcast(msg);
|
||||
}
|
||||
request->send(200, "text/plain", msg);
|
||||
}
|
||||
@@ -144,7 +156,8 @@ class IlluCat : public MeshSprocket {
|
||||
}
|
||||
|
||||
void loop(){
|
||||
MeshSprocket::loop();
|
||||
Sprocket::loop();
|
||||
yield();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -14,11 +14,14 @@
|
||||
#define SPROCKET_MODE 0
|
||||
#define WIFI_CHANNEL 11
|
||||
#define MESH_PORT 5555
|
||||
#define AP_SSID "illucat"
|
||||
#define AP_PASSWORD "illumination"
|
||||
#define MESH_PREFIX "illucat-mesh"
|
||||
#define MESH_PASSWORD "th3r31sn0sp00n"
|
||||
#define STATION_SSID "MyAP"
|
||||
#define STATION_PASSWORD "th3r31sn0sp00n"
|
||||
#define HOSTNAME "illucat"
|
||||
#define CONNECT_TIMEOUT 10000
|
||||
#define MESH_DEBUG_TYPES ERROR | STARTUP | CONNECTION
|
||||
//ERROR | MESH_STATUS | CONNECTION | SYNC | COMMUNICATION | GENERAL | MSG_TYPES | REMOTE
|
||||
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
#include "config.h"
|
||||
#include "MeshNet.h"
|
||||
//#include "MeshNet.h"
|
||||
#include "WiFiNet.h"
|
||||
#include "IlluCat.h"
|
||||
|
||||
MeshNet net({
|
||||
/* MeshNet net({
|
||||
SPROCKET_MODE, WIFI_CHANNEL,
|
||||
MESH_PORT, MESH_PREFIX, MESH_PASSWORD,
|
||||
STATION_SSID, STATION_PASSWORD, HOSTNAME,
|
||||
MESH_DEBUG_TYPES
|
||||
});
|
||||
}); */
|
||||
WiFiNet net(SPROCKET_MODE,STATION_SSID, STATION_PASSWORD,AP_SSID, AP_PASSWORD,HOSTNAME,CONNECT_TIMEOUT);
|
||||
IlluCat sprocket(
|
||||
{ STARTUP_DELAY, SERIAL_BAUD_RATE },
|
||||
{ OTA_PORT, OTA_PASSWORD },
|
||||
|
||||
Reference in New Issue
Block a user