cleanup examples, build and ci

This commit is contained in:
2018-11-08 15:25:17 +01:00
parent 12b9a7b509
commit 7273ee6a0b
14 changed files with 65 additions and 102 deletions

View File

@@ -34,11 +34,10 @@ firmware-build:
stage: build
image: python:2.7-stretch
script:
- pio run -t clean
- pio run --target clean
- pio run --environment basic
- pio run --environment mesh
- pio run --environment meshMqttBridge
- pio run --environment standalone
- pio run --environment wifi
- pio run --environment wifiMesh
artifacts:
paths:
- .pioenvs/*/firmware.*

View File

@@ -46,8 +46,8 @@ monitor_baud = ${common.monitor_baud}
framework = ${common.framework}
lib_deps = ${common.lib_deps}
[env:mesh]
src_filter = +<*> -<examples/> +<examples/mesh/>
[env:wifiMesh]
src_filter = +<*> -<examples/> +<examples/wifiMesh/>
platform = ${common.platform}
board = ${common.board}
upload_speed = ${common.upload_speed}
@@ -55,19 +55,13 @@ monitor_baud = ${common.monitor_baud}
framework = ${common.framework}
lib_deps = ${common.lib_deps}
painlessMesh
ESP8266mDNS
ArduinoOTA
ESP Async WebServer
ESPAsyncTCP
;upload_port = 192.168.1.247
[env:standalone]
src_filter = +<*> -<examples/> +<examples/standalone/>
[env:wifi]
src_filter = +<*> -<examples/> +<examples/wifi/>
platform = ${common.platform}
board = ${common.board}
upload_speed = ${common.upload_speed}
monitor_baud = ${common.monitor_baud}
framework = ${common.framework}
lib_deps = ${common.lib_deps}
ArduinoOTA
ESP Async WebServer

View File

@@ -28,6 +28,7 @@ int MeshNet::connect(){
if(config.stationMode){
connectStation();
}
return 1;
}
int MeshNet::connectStation() {

View File

@@ -1,46 +0,0 @@
#ifndef __WIFI_APP__
#define __WIFI_APP__
#include <TaskScheduler.h>
#include <Sprocket.h>
#include <plugins/WebServerConfig.h>
//#include <plugins/OtaTcpPlugin.cpp>
#include <plugins/WebServerPlugin.cpp>
#include <plugins/WebConfigPlugin.cpp>
#include "Mediator.h"
using namespace std;
using namespace std::placeholders;
AsyncWebServer WEBSERVER(80);
class WiFiApp : public Sprocket {
public:
Scheduler* ts;
Task someTask;
WiFiApp(SprocketConfig cfg, /* OtaConfig otaCfg, */ WebServerConfig webCfg) : Sprocket(cfg) {
//addPlugin(new OtaTcpPlugin(otaCfg));
addPlugin(new WebServerPlugin(webCfg, &WEBSERVER));
addPlugin(new WebConfigPlugin(&WEBSERVER));
ts = new Scheduler();
}
Sprocket* activate(Scheduler* scheduler) {
Sprocket::activate(ts);
Serial.println("activate WiFiApp");
// add a task
someTask.set(TASK_SECOND, TASK_FOREVER, [](){
Serial.println("do stuff in task");
});
//addTask(someTask);
return this;
} using Sprocket::activate;
void loop(){
//Sprocket::loop();
ts->execute();
yield();
}
};
#endif

View File

@@ -1,30 +0,0 @@
#include "config.h"
#include "WiFiNet.h"
#include "WiFiApp.h"
/* WiFiConfig wifiCfg = {
.stationMode=SPROCKET_MODE,
.stationSSID=STATION_SSID,
.stationPassword=STATION_PASSWORD,
.apSSID=AP_SSID,
.apPassword=AP_PASSWORD,
.hostname=HOSTNAME,
.connectTimeout=CONNECT_TIMEOUT
}; */
WiFiNet net(SPROCKET_MODE,STATION_SSID, STATION_PASSWORD,AP_SSID, AP_PASSWORD,HOSTNAME,CONNECT_TIMEOUT);
WiFiApp sprocket(
{ STARTUP_DELAY, SERIAL_BAUD_RATE },
/* { OTA_PORT, OTA_PASSWORD }, */
{ WEB_CONTEXT_PATH, WEB_DOC_ROOT, WEB_DEFAULT_FILE }
);
void setup() {
delay(3000);
sprocket.join(net);
}
void loop() {
sprocket.loop();
yield();
}

View File

@@ -0,0 +1,24 @@
#ifndef __WIFI_APP__
#define __WIFI_APP__
#include <TaskScheduler.h>
#include <Sprocket.h>
#include <plugins/WebServerConfig.h>
#include <plugins/WebServerPlugin.cpp>
#include <plugins/WebConfigPlugin.cpp>
using namespace std;
using namespace std::placeholders;
class WiFiApp : public Sprocket {
public:
AsyncWebServer* server;
WiFiApp(SprocketConfig cfg, WebServerConfig webCfg) : Sprocket(cfg) {
server = new AsyncWebServer(webCfg.port);
addPlugin(new WebServerPlugin(webCfg, server));
addPlugin(new WebConfigPlugin(server));
}
};
#endif

View File

@@ -27,5 +27,6 @@
#define WEB_CONTEXT_PATH "/"
#define WEB_DOC_ROOT "/www"
#define WEB_DEFAULT_FILE "index.html"
#define WEB_SERVER_PORT 80
#endif

View File

@@ -0,0 +1,28 @@
#include "config.h"
#include "WiFiNet.h"
#include "WiFiApp.h"
WiFiNet wifi(
SPROCKET_MODE,
STATION_SSID,
STATION_PASSWORD,
AP_SSID,
AP_PASSWORD,
HOSTNAME,
CONNECT_TIMEOUT);
WiFiApp sprocket(
{STARTUP_DELAY, SERIAL_BAUD_RATE},
{WEB_CONTEXT_PATH, WEB_DOC_ROOT, WEB_DEFAULT_FILE, WEB_SERVER_PORT});
void setup()
{
delay(3000);
wifi.connect();
sprocket.activate();
}
void loop()
{
sprocket.loop();
yield();
}

View File

@@ -4,26 +4,18 @@
#include <Sprocket.h>
#include <MeshNet.h>
#include <plugins/MeshNetworkPlugin.cpp>
#include <plugins/WebServerConfig.h>
#include <plugins/WebServerPlugin.cpp>
#include <plugins/WebConfigPlugin.cpp>
#include "Mediator.h"
using namespace std;
using namespace std::placeholders;
AsyncWebServer WEBSERVER(80);
class MeshApp : public Sprocket
{
public:
Task heartbeatTask;
MeshApp(SprocketConfig cfg, MeshConfig meshCfg, WebServerConfig webCfg) : Sprocket(cfg)
MeshApp(SprocketConfig cfg, MeshConfig meshCfg) : Sprocket(cfg)
{
addPlugin(new MeshNetworkPlugin(meshCfg));
addPlugin(new WebServerPlugin(webCfg, &WEBSERVER));
addPlugin(new WebConfigPlugin(&WEBSERVER));
subscribe("device/heartbeat", bind(&MeshApp::messageHandler, this, _1));
}

View File

@@ -6,8 +6,7 @@ MeshApp sprocket(
{SPROCKET_MODE, WIFI_CHANNEL,
MESH_PORT, MESH_PREFIX, MESH_PASSWORD,
STATION_SSID, STATION_PASSWORD, HOSTNAME,
MESH_DEBUG_TYPES},
{WEB_CONTEXT_PATH, WEB_DOC_ROOT, WEB_DEFAULT_FILE});
MESH_DEBUG_TYPES});
void setup()
{

View File

@@ -27,8 +27,8 @@ class MeshNetworkPlugin : public NetworkPlugin
{
userScheduler->setHighPriorityScheduler(meshScheduler);
network->onReceive(bind(&MeshNetworkPlugin::dispatch, this, _1, _2));
// TODO base subscribers
subscribe("mesh/broadcast", bind(&MeshNetworkPlugin::broadcast, this, _1));
// TODO mesh/sendTo
NetworkPlugin::activate(meshScheduler);
}
void broadcast(String msg)

View File

@@ -5,6 +5,7 @@ struct WebServerConfig {
const char* contextPath;
const char* docRoot;
const char* defaultFile;
int port;
};
#endif