mirror of
https://gitlab.com/zwirbel/illucat.git
synced 2025-12-16 18:05:05 +01:00
multiple web config
This commit is contained in:
@@ -11,11 +11,24 @@
|
|||||||
<button class="js-restart">Restart</button>
|
<button class="js-restart">Restart</button>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
|
<fieldset>
|
||||||
|
<legend>Network</legend>
|
||||||
<form action="/config" method="post">
|
<form action="/config" method="post">
|
||||||
|
<input type="hidden" name="fileName" value="/config.json">
|
||||||
<textarea name="config" class="js-config" rows="20" cols="50"></textarea>
|
<textarea name="config" class="js-config" rows="20" cols="50"></textarea>
|
||||||
<br>
|
<br>
|
||||||
<input type="submit" value="Submit">
|
<input type="submit" value="Submit">
|
||||||
</form>
|
</form>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<legend>NeoPixel Config</legend>
|
||||||
|
<form action="/config" method="post">
|
||||||
|
<input type="hidden" name="fileName" value="/pixelConfig.json">
|
||||||
|
<textarea name="config" class="js-config" rows="20" cols="50"></textarea>
|
||||||
|
<br>
|
||||||
|
<input type="submit" value="Submit">
|
||||||
|
</form>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,16 @@
|
|||||||
// mesh topology:
|
|
||||||
const exampleMesh = [{
|
|
||||||
"nodeId": 757307929, "subs": [
|
|
||||||
{ "nodeId": 2138241514, "subs": [] },
|
|
||||||
{ "nodeId": 757307466, "subs": [] }
|
|
||||||
]
|
|
||||||
}, {
|
|
||||||
"nodeId": 757308244, "subs": [
|
|
||||||
{ "nodeId": 3154639577, "subs": [] }
|
|
||||||
]
|
|
||||||
}, {
|
|
||||||
"nodeId": 3954439712, "subs": []
|
|
||||||
}];
|
|
||||||
|
|
||||||
$(() => {
|
$(() => {
|
||||||
// load config
|
|
||||||
$.get("/config.json", (data) => {
|
$('form').each((i, el) => {
|
||||||
$('.js-config').val(JSON.stringify(data, null, 4));
|
let $fEl = $(el);
|
||||||
|
$.get($fEl.find('[name="fileName"]').val(), (data) => {
|
||||||
|
$fEl.find('.js-config').val(JSON.stringify(data, null, 4));
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// load config
|
||||||
|
//$.get("/config.json", (data) => {
|
||||||
|
// $('.js-config').val(JSON.stringify(data, null, 4));
|
||||||
|
//});
|
||||||
// add handlers
|
// add handlers
|
||||||
$('.js-restart').click(() => {
|
$('.js-restart').click(() => {
|
||||||
$.post('/restart');
|
$.post('/restart');
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ class IlluCat : public MeshSprocket {
|
|||||||
defaultAnimation();
|
defaultAnimation();
|
||||||
|
|
||||||
// setup web stuff
|
// setup web stuff
|
||||||
|
server->serveStatic("/pixelConfig.json", SPIFFS, "pixelConfig.json");
|
||||||
server->on("/pixel/pattern", HTTP_POST, bind(&IlluCat::patternWebRequestHandler, this, _1));
|
server->on("/pixel/pattern", HTTP_POST, bind(&IlluCat::patternWebRequestHandler, this, _1));
|
||||||
ws->onEvent(bind(&IlluCat::onWsEvent, this, _1, _2, _3, _4, _5, _6));
|
ws->onEvent(bind(&IlluCat::onWsEvent, this, _1, _2, _3, _4, _5, _6));
|
||||||
server->addHandler(ws);
|
server->addHandler(ws);
|
||||||
@@ -126,7 +127,9 @@ class IlluCat : public MeshSprocket {
|
|||||||
|
|
||||||
virtual void onNewConnection(uint32_t nodeId){
|
virtual void onNewConnection(uint32_t nodeId){
|
||||||
PRINT_MSG(Serial, SPROCKET_TYPE, "connected to %u", nodeId);
|
PRINT_MSG(Serial, SPROCKET_TYPE, "connected to %u", nodeId);
|
||||||
defaultAnimation();
|
//defaultAnimation();
|
||||||
|
String stateJson = state.toJsonString();
|
||||||
|
net->mesh.sendSingle(nodeId, stateJson);
|
||||||
// TODO publish current state to pixel/color on new node
|
// TODO publish current state to pixel/color on new node
|
||||||
}
|
}
|
||||||
virtual void onConnectionChanged(){
|
virtual void onConnectionChanged(){
|
||||||
|
|||||||
Reference in New Issue
Block a user