Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
724459a
Merge pull request #39 from DutchDevelop/main
softwarecrash Jul 2, 2025
a8da251
Fix aditional newline in webserial when timestamp activated
softwarecrash Jul 2, 2025
982e490
Fix Zero value bug in JS
softwarecrash Jul 4, 2025
2f95374
fix typo
softwarecrash Jul 4, 2025
819c248
Create push-to-blledflasher.yml
softwarecrash Jul 5, 2025
e6305da
Delete .github/workflows directory
softwarecrash Jul 5, 2025
325c3d1
Create push-to-blledflasher.yml
softwarecrash Jul 5, 2025
0b10da9
reduce doortest function time to 2 seconds
softwarecrash Jul 7, 2025
a9db31e
correct sort
softwarecrash Jul 7, 2025
6c3ee79
another doorfix
softwarecrash Jul 9, 2025
e0c1131
Merge pull request #40 from softwarecrash/Refactoring
softwarecrash Jul 9, 2025
f8a9e68
version correct
softwarecrash Jul 9, 2025
5194624
Merge pull request #42 from softwarecrash/Refactoring
softwarecrash Jul 10, 2025
b415966
version Bump
softwarecrash Jul 10, 2025
fcf2fc0
Merge branch 'main' into main
softwarecrash Jul 10, 2025
58a90e7
Add self
softwarecrash Jul 10, 2025
b972b0f
catch buffer overflow
softwarecrash Jul 14, 2025
1d5c715
correct
softwarecrash Jul 15, 2025
528ffc5
add log
softwarecrash Jul 15, 2025
d3e16a1
fix uppercase input issue
softwarecrash Sep 2, 2025
6e07cea
Merge pull request #45 from softwarecrash/mqtt-rework
softwarecrash Sep 2, 2025
408d0ae
discovery button more present
softwarecrash Sep 4, 2025
8225167
version bump
softwarecrash Sep 4, 2025
c73633e
version bump
softwarecrash Sep 7, 2025
670c09f
Merge pull request #46 from softwarecrash/mqtt-rework
softwarecrash Sep 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/push-to-blledflasher.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Push Firmware to BLLED-Flasher

on:
release:
types: [published, edited]

jobs:
push-firmware:
runs-on: ubuntu-latest

steps:
- name: Checkout BLLEDController-NG
uses: actions/checkout@v3

- name: Download .bin from current release
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const owner = context.repo.owner;
const repo = context.repo.repo;
const release = context.payload.release;
const tag = release.tag_name;

const assets = release.assets.filter(a => a.name.endsWith('.bin'));
if (assets.length === 0) {
core.setFailed("No .bin files found in release");
return;
}

fs.mkdirSync('firmware', { recursive: true });

for (const asset of assets) {
const dl = await github.rest.repos.getReleaseAsset({
owner,
repo,
asset_id: asset.id,
headers: { Accept: 'application/octet-stream' }
});

fs.writeFileSync(`firmware/${asset.name}`, Buffer.from(dl.data));
console.log(`✅ Downloaded: ${asset.name}`);
}

- name: Clone BLLED-Flasher repo
run: |
git clone https://x-access-token:${{ secrets.BLLED_FLASHER_TOKEN }}@github.com/softwarecrash/BLLED-Flasher.git flasher
cp firmware/*.bin flasher/firmware/

- name: Generate firmware.json + manifests
run: |
cd flasher
node generateRelease.js

- name: Commit and Push to BLLED-Flasher
run: |
cd flasher
git config user.name "BLLED Release Bot"
git config user.email "[email protected]"
git fetch origin
git add firmware/
if git diff --cached --quiet; then
echo "✅ Keine Änderungen – kein Push."
else
git commit -m "📦 Add firmware from release ${{ github.event.release.tag_name }}"
git push
fi
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ The BL Led Controller is released under Creative Commons Attribution-NonCommerci
- **[Modbot](https://github.com/Modbot)**: Tester for X1C, P1P & P1S
- **[xps3riments](https://github.com/xps3riments)**: Inspiration for the foundation of the code
- **[longrackslabs](https://github.com/longrackslabs)**: Build process, documentation, developer & community support
- **[SoftWareCrash](https://github.com/softwarecrash)**: Any small unimportant changes

### Author

Expand Down
4 changes: 2 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[env:esp32dev]
custom_project_name = BLLC
custom_project_codename = Balder
custom_version = 2.2.2 #BLLC_[Major].[Minor].[Patch]
custom_version = 2.2.3.nightly.070925.1 #BLLC_[Major].[Minor].[Patch]
platform = espressif32
board = esp32dev
framework = arduino
Expand All @@ -31,4 +31,4 @@ lib_deps =
luc-github/[email protected]
ESP32Async/AsyncTCP
ESP32Async/ESPAsyncWebServer
mathieucarbou/MycilaWebSerial@^8.1.1
mathieucarbou/MycilaWebSerial@^8.1.1
6 changes: 6 additions & 0 deletions src/blled/AutoGrowBufferStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <Stream.h>

#define BUFFER_INCREMENTS 128
#define MAX_BUFFER_SIZE 65536

class AutoGrowBufferStream : public Stream
{
Expand All @@ -26,6 +27,11 @@ class AutoGrowBufferStream : public Stream
}

virtual size_t write(uint8_t byte) {
if (this->_len + 1 > MAX_BUFFER_SIZE) {
LogSerial.println(F("Max buffer size reached — flushing"));
this->flush();
return 0;
}
if (this->_len + 1 > this->buffer_size) {
auto tmp = (char*)realloc(this->_buffer, this->buffer_size + BUFFER_INCREMENTS);
if (tmp == NULL) {
Expand Down
2 changes: 1 addition & 1 deletion src/blled/leds.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ void updateleds()

if (printerConfig.debugingchange)
{
LogSerial.print(F("Door closed twice within 6 seconds - "));
LogSerial.print(F("Door closed twice within 2 seconds - "));

if (ledsAreOff)
LogSerial.print(F("Turning LEDs ON"));
Expand Down
79 changes: 43 additions & 36 deletions src/blled/mqttmanager.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef _MQTTMANAGER
#define _MQTTMANAGER

#define TASK_RAM 20480 // 20kB for MQTT Task Stack Size

#include <Arduino.h>
#include <WiFi.h>
#include <WiFiClientSecure.h>
Expand Down Expand Up @@ -180,6 +182,7 @@ void mqttTask(void *parameter)

mqttTaskRunning = false;
vTaskDelete(NULL);
LogSerial.printf("[MQTT Task] HighWaterMark: %d bytes\n", uxTaskGetStackHighWaterMark(NULL));
}

void ParseCallback(char *topic, byte *payload, unsigned int length)
Expand All @@ -188,14 +191,6 @@ void ParseCallback(char *topic, byte *payload, unsigned int length)
JsonDocument filter;
// Rather than showing the entire message to Serial - grabbing only the pertinent bits for BLLED.
// Device Status

// sniped: implement to get layer num. for hms error, swap back to running state after layer change
/* "print": {
"3D": {
"layer_num": 0,
"total_layer_num": 191
} */

filter["print"]["command"] = true;
filter["print"]["fail_reason"] = true;
filter["print"]["gcode_state"] = true;
Expand Down Expand Up @@ -245,7 +240,7 @@ void ParseCallback(char *topic, byte *payload, unsigned int length)
if (printerConfig.mqttdebug)
{
LogSerial.print(F("(Filtered) MQTT payload, ["));
LogSerial.print(millis());
LogSerial.print(stream.current_length());
LogSerial.print(F("], "));
serializeJson(messageobject, LogSerial);
LogSerial.println();
Expand Down Expand Up @@ -329,6 +324,7 @@ if (!messageobject["print"]["home_flag"].isNull())
printerVariables.printerledstate = true;
printerConfig.replicate_update = false;
controlChamberLight(true);
printerVariables.stage = 255;
LogSerial.println(F("[MQTT] Door opened – Light forced ON"));
}

Expand All @@ -340,33 +336,44 @@ if (!messageobject["print"]["home_flag"].isNull())
updateleds();
}

// Door closed
else
{
printerVariables.lastdoorClosems = millis();
else // Door closed
{
printerVariables.lastdoorClosems = millis();

// If light was forced on by door, turn it off now
if (printerVariables.chamberLightLocked)
{
printerVariables.chamberLightLocked = false;
printerVariables.printerledstate = false;
controlChamberLight(false);
LogSerial.println(F("[MQTT] Door closed – Light OFF and lock released"));
}
// Turn off chamber light if enabled
if (printerConfig.controlChamberLight)
{
//controlChamberLight(false);
printerVariables.chamberLightLocked = false;
//LogSerial.println(F("[MQTT] Door closed – Chamber light OFF"));
}

// Restart inactivity timer
printerConfig.inactivityStartms = millis();
printerConfig.isIdleOFFActive = false;
if (!printerConfig.inactivityEnabled)
{
// Turn off LED bar immediately
printerVariables.printerledstate = false;
printerConfig.replicate_update = false;
printerVariables.stage = 999;
tweenToColor(0,0,0,0,0);
controlChamberLight(false);
LogSerial.println(F("[MQTT] Door closed – LED bar OFF (inactivity disabled)"));
}

// Detect double-close toggle
if ((millis() - printerVariables.lastdoorOpenms) < 6000)
{
printerVariables.doorSwitchTriggered = true;
}
// Reset inactivity timer
printerConfig.inactivityStartms = millis();
printerConfig.isIdleOFFActive = false;

// Double-close detection
if ((millis() - printerVariables.lastdoorOpenms) < 2000)
{
printerVariables.doorSwitchTriggered = true;
}

Changed = true;
updateleds();

}

Changed = true;
updateleds();
}
}
}

Expand Down Expand Up @@ -680,8 +687,8 @@ void setupMqtt()
report_topic = device_topic + String("/report");

wifiSecureClient.setInsecure();
wifiSecureClient.setTimeout(10);
mqttClient.setSocketTimeout(10);
wifiSecureClient.setTimeout(15);
mqttClient.setSocketTimeout(17);
mqttClient.setBufferSize(1024);
mqttClient.setServer(printerConfig.printerIP, 8883);
mqttClient.setStream(stream);
Expand All @@ -697,15 +704,15 @@ void setupMqtt()
result = xTaskCreate(
mqttTask,
"mqttTask",
6144,
TASK_RAM,
NULL,
1,
&mqttTaskHandle);
#else
result = xTaskCreatePinnedToCore(
mqttTask,
"mqttTask",
6144,
TASK_RAM,
NULL,
1,
&mqttTaskHandle,
Expand Down
4 changes: 3 additions & 1 deletion src/blled/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ extern "C"
unsigned long lastdoorClosems = 0; // Last time door was opened
unsigned long lastdoorOpenms = 0; // Last time door was closed
bool chamberLightLocked = false; // blocks replicate while true
bool ledWasForcedByDoor = false;
} PrinterVariables;
PrinterVariables printerVariables;

typedef struct SecurityVariables{
// Security
Expand All @@ -51,7 +53,7 @@ extern "C"
}SecurityVariables;
SecurityVariables securityVariables;

PrinterVariables printerVariables;


typedef struct GlobalVariablesStruct{
char SSID[32];
Expand Down
Loading