Compare commits

...

5 Commits

Author SHA1 Message Date
e4d1ba6c1c docs: update changelog and header for version v1.5.9
All checks were successful
Release Workflow / detect-provider (push) Successful in 4s
Release Workflow / github-release (push) Has been skipped
Release Workflow / gitea-release (push) Successful in 3m31s
2025-08-11 14:18:12 +02:00
88598611c5 docs: update platformio.ini for version v1.5.9 2025-08-11 14:18:12 +02:00
377f4bc146 Enhance API to support weight updates after successful spool tag updates 2025-08-11 14:17:57 +02:00
7cbd34bc91 docs: update changelog and header for version v1.5.8
All checks were successful
Release Workflow / detect-provider (push) Successful in 52s
Release Workflow / github-release (push) Has been skipped
Release Workflow / gitea-release (push) Successful in 3m19s
2025-08-10 14:39:44 +02:00
f7484f635e docs: update platformio.ini for version v1.5.8 2025-08-10 14:39:44 +02:00
3 changed files with 104 additions and 10 deletions

View File

@@ -1,5 +1,35 @@
# Changelog
## [1.5.9] - 2025-08-11
### Changed
- update platformio.ini for version v1.5.9
- Enhance API to support weight updates after successful spool tag updates
## [1.5.8] - 2025-08-10
### Added
- Adds a link to the spool in spoolman when reading a spool tag
- Fixes types and some issues in the new graphics
### Changed
- update platformio.ini for version v1.5.8
- Merge pull request #45 from janecker/nfc_write_improvements
- Introduces periodic Spoolman Healthcheck
- Improves init - NFC reading now only starts after boot is finished
- Further improvements on NFC writing
- Merge pull request #44 from janecker/graphics_rework
- Graphic rework of the NFC writing process
- Remove unused parameter of sendNfcData()
- Reworks startup graphics and timings
### Fixed
- Fixes issue that scale not calibrated message was not shown
- Improves NFC writing workaround and removes debug output
- Fixes typos in upgrade page
- Reworks graphics of tag reading and some api fixes
- Replaces usage of String with const char* in heap debug function
## [1.5.7] - 2025-07-28
### Changed
- update platformio.ini for version v1.5.7

View File

@@ -9,7 +9,7 @@
; https://docs.platformio.org/page/projectconf.html
[common]
version = "1.5.7"
version = "1.5.9"
to_old_version = "1.5.0"
##

View File

@@ -4,6 +4,7 @@
#include "commonFS.h"
#include <Preferences.h>
#include "debug.h"
#include "scale.h"
volatile spoolmanApiStateType spoolmanApiState = API_IDLE;
//bool spoolman_connected = false;
@@ -23,6 +24,10 @@ struct SendToApiParams {
String spoolsUrl;
String updatePayload;
String octoToken;
// Weight update parameters for sequential execution
bool triggerWeightUpdate;
String spoolIdForWeight;
uint16_t weightValue;
};
JsonDocument fetchSingleSpoolInfo(int spoolId) {
@@ -104,12 +109,15 @@ void sendToApi(void *parameter) {
spoolmanApiState = API_TRANSMITTING;
SendToApiParams* params = (SendToApiParams*)parameter;
// Extrahiere die Werte
// Extract values including weight update parameters
SpoolmanApiRequestType requestType = params->requestType;
String httpType = params->httpType;
String spoolsUrl = params->spoolsUrl;
String updatePayload = params->updatePayload;
String octoToken = params->octoToken;
String octoToken = params->octoToken;
bool triggerWeightUpdate = params->triggerWeightUpdate;
String spoolIdForWeight = params->spoolIdForWeight;
uint16_t weightValue = params->weightValue;
HTTPClient http;
http.setReuse(false);
@@ -163,6 +171,57 @@ void sendToApi(void *parameter) {
}
}
doc.clear();
// Execute weight update if requested and tag update was successful
if (triggerWeightUpdate && requestType == API_REQUEST_SPOOL_TAG_ID_UPDATE && weightValue > 10) {
Serial.println("Executing weight update after successful tag update");
// Prepare weight update request
String weightUrl = spoolmanUrl + apiUrl + "/spool/" + spoolIdForWeight + "/measure";
JsonDocument weightDoc;
weightDoc["weight"] = weightValue;
String weightPayload;
serializeJson(weightDoc, weightPayload);
Serial.print("Weight update URL: ");
Serial.println(weightUrl);
Serial.print("Weight update payload: ");
Serial.println(weightPayload);
// Execute weight update
http.begin(weightUrl);
http.addHeader("Content-Type", "application/json");
int weightHttpCode = http.PUT(weightPayload);
if (weightHttpCode == HTTP_CODE_OK) {
Serial.println("Weight update successful");
String weightResponse = http.getString();
JsonDocument weightResponseDoc;
DeserializationError weightError = deserializeJson(weightResponseDoc, weightResponse);
if (!weightError) {
remainingWeight = weightResponseDoc["remaining_weight"].as<uint16_t>();
Serial.print("Updated weight: ");
Serial.println(remainingWeight);
if (!octoEnabled) {
oledShowProgressBar(1, 1, "Spool Tag", ("Done: " + String(remainingWeight) + " g remain").c_str());
remainingWeight = 0;
} else {
sendOctoUpdate = true;
}
}
weightResponseDoc.clear();
} else {
Serial.print("Weight update failed with HTTP code: ");
Serial.println(weightHttpCode);
oledShowProgressBar(1, 1, "Failure!", "Weight update");
}
weightDoc.clear();
}
} else {
switch(requestType){
case API_REQUEST_SPOOL_WEIGHT_UPDATE:
@@ -211,7 +270,8 @@ bool updateSpoolTagId(String uidString, const char* payload) {
return false;
}
String spoolsUrl = spoolmanUrl + apiUrl + "/spool/" + doc["sm_id"].as<String>();
String spoolId = doc["sm_id"].as<String>();
String spoolsUrl = spoolmanUrl + apiUrl + "/spool/" + spoolId;
Serial.print("Update Spule mit URL: ");
Serial.println(spoolsUrl);
@@ -235,22 +295,26 @@ bool updateSpoolTagId(String uidString, const char* payload) {
params->httpType = "PATCH";
params->spoolsUrl = spoolsUrl;
params->updatePayload = updatePayload;
// Add weight update parameters for sequential execution
params->triggerWeightUpdate = (weight > 10);
params->spoolIdForWeight = spoolId;
params->weightValue = weight;
// Erstelle die Task
// Erstelle die Task mit erhöhter Stackgröße für zusätzliche HTTP-Anfrage
BaseType_t result = xTaskCreate(
sendToApi, // Task-Funktion
"SendToApiTask", // Task-Name
6144, // Stackgröße in Bytes
8192, // Erhöhte Stackgröße für zusätzliche HTTP-Anfrage
(void*)params, // Parameter
0, // Priorität
apiTask // Task-Handle (nicht benötigt)
apiTask // Task-Handle (nicht benötigt)
);
updateDoc.clear();
// Update Spool weight
//TBD: how to handle this with spool and locatin tags? Also potential parallel access again
//if (weight > 10) updateSpoolWeight(doc["sm_id"].as<String>(), weight);
// Update Spool weight now handled sequentially in sendToApi task
// to prevent parallel API access issues
return true;
}