Compare commits
6 Commits
v1.5.12-be
...
v1.5.12-be
Author | SHA1 | Date | |
---|---|---|---|
2587227e78 | |||
0f19dc4f46 | |||
721dac1ead | |||
08abd1a37f | |||
da78861613 | |||
9231a303f3 |
14
CHANGELOG.md
14
CHANGELOG.md
@@ -1,5 +1,19 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [1.5.12-beta11] - 2025-08-29
|
||||||
|
### Changed
|
||||||
|
- update platformio.ini for beta version v1.5.12-beta11
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- update spoolman ID reset values to 65535 for better API response detection
|
||||||
|
|
||||||
|
|
||||||
|
## [1.5.12-beta10] - 2025-08-29
|
||||||
|
### Changed
|
||||||
|
- update platformio.ini for beta version v1.5.12-beta10
|
||||||
|
- streamline task creation in checkVendor and checkFilament functions
|
||||||
|
|
||||||
|
|
||||||
## [1.5.12-beta9] - 2025-08-29
|
## [1.5.12-beta9] - 2025-08-29
|
||||||
### Added
|
### Added
|
||||||
- update vendor and filament ID handling to use NULL and add delays for stability
|
- update vendor and filament ID handling to use NULL and add delays for stability
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[common]
|
[common]
|
||||||
version = "1.5.12-beta9"
|
version = "1.5.12-beta11"
|
||||||
to_old_version = "1.5.0"
|
to_old_version = "1.5.0"
|
||||||
|
|
||||||
##
|
##
|
||||||
|
79
src/api.cpp
79
src/api.cpp
@@ -5,6 +5,7 @@
|
|||||||
#include <Preferences.h>
|
#include <Preferences.h>
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "scale.h"
|
#include "scale.h"
|
||||||
|
#include "nfc.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
volatile spoolmanApiStateType spoolmanApiState = API_IDLE;
|
volatile spoolmanApiStateType spoolmanApiState = API_IDLE;
|
||||||
|
|
||||||
@@ -151,7 +152,7 @@ void sendToApi(void *parameter) {
|
|||||||
else httpCode = http.PUT(updatePayload);
|
else httpCode = http.PUT(updatePayload);
|
||||||
|
|
||||||
if (httpCode == HTTP_CODE_OK) {
|
if (httpCode == HTTP_CODE_OK) {
|
||||||
Serial.println("Spoolman erfolgreich aktualisiert");
|
Serial.println("Spoolman Abfrage erfolgreich");
|
||||||
|
|
||||||
// Restgewicht der Spule auslesen
|
// Restgewicht der Spule auslesen
|
||||||
String payload = http.getString();
|
String payload = http.getString();
|
||||||
@@ -676,7 +677,7 @@ uint16_t createVendor(String vendor) {
|
|||||||
|
|
||||||
uint16_t checkVendor(String vendor) {
|
uint16_t checkVendor(String vendor) {
|
||||||
// Check if vendor exists using task system
|
// Check if vendor exists using task system
|
||||||
foundVendorId = NULL; // Reset previous value
|
foundVendorId = 65535; // Reset to invalid value to detect when API response is received
|
||||||
|
|
||||||
String vendorName = vendor;
|
String vendorName = vendor;
|
||||||
vendorName.trim();
|
vendorName.trim();
|
||||||
@@ -701,30 +702,18 @@ uint16_t checkVendor(String vendor) {
|
|||||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Erstelle die Task
|
||||||
if(spoolmanApiState == API_IDLE) {
|
BaseType_t result = xTaskCreate(
|
||||||
// Erstelle die Task
|
sendToApi, // Task-Funktion
|
||||||
BaseType_t result = xTaskCreate(
|
"SendToApiTask", // Task-Name
|
||||||
sendToApi, // Task-Funktion
|
6144, // Stackgröße in Bytes
|
||||||
"SendToApiTask", // Task-Name
|
(void*)params, // Parameter
|
||||||
6144, // Stackgröße in Bytes
|
0, // Priorität
|
||||||
(void*)params, // Parameter
|
NULL // Task-Handle (nicht benötigt)
|
||||||
0, // Priorität
|
);
|
||||||
NULL // Task-Handle (nicht benötigt)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
Serial.println("Not spawning new task, API still active!");
|
|
||||||
delete params;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wait for task completion
|
// Wait until foundVendorId is updated by the API response (not 65535 anymore)
|
||||||
while(spoolmanApiState != API_IDLE) {
|
while (foundVendorId == 65535)
|
||||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Additional delay to ensure foundVendorId is properly set after API state becomes IDLE
|
|
||||||
while (foundVendorId == NULL)
|
|
||||||
{
|
{
|
||||||
vTaskDelay(50 / portTICK_PERIOD_MS);
|
vTaskDelay(50 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
@@ -836,7 +825,7 @@ uint16_t createFilament(uint16_t vendorId, const JsonDocument& payload) {
|
|||||||
|
|
||||||
uint16_t checkFilament(uint16_t vendorId, const JsonDocument& payload) {
|
uint16_t checkFilament(uint16_t vendorId, const JsonDocument& payload) {
|
||||||
// Check if filament exists using task system
|
// Check if filament exists using task system
|
||||||
foundFilamentId = NULL; // Reset previous value
|
foundFilamentId = 65535; // Reset to invalid value to detect when API response is received
|
||||||
|
|
||||||
String spoolsUrl = spoolmanUrl + apiUrl + "/filament?vendor.id=" + String(vendorId) + "&external_id=" + String(payload["artnr"].as<String>());
|
String spoolsUrl = spoolmanUrl + apiUrl + "/filament?vendor.id=" + String(vendorId) + "&external_id=" + String(payload["artnr"].as<String>());
|
||||||
Serial.print("Check filament with URL: ");
|
Serial.print("Check filament with URL: ");
|
||||||
@@ -852,30 +841,18 @@ uint16_t checkFilament(uint16_t vendorId, const JsonDocument& payload) {
|
|||||||
params->spoolsUrl = spoolsUrl;
|
params->spoolsUrl = spoolsUrl;
|
||||||
params->updatePayload = ""; // Empty for GET request
|
params->updatePayload = ""; // Empty for GET request
|
||||||
|
|
||||||
// Check if API is idle before creating task
|
// Erstelle die Task
|
||||||
//if(spoolmanApiState == API_IDLE){
|
BaseType_t result = xTaskCreate(
|
||||||
// Erstelle die Task
|
sendToApi, // Task-Funktion
|
||||||
BaseType_t result = xTaskCreate(
|
"SendToApiTask", // Task-Name
|
||||||
sendToApi, // Task-Funktion
|
6144, // Stackgröße in Bytes
|
||||||
"SendToApiTask", // Task-Name
|
(void*)params, // Parameter
|
||||||
6144, // Stackgröße in Bytes
|
0, // Priorität
|
||||||
(void*)params, // Parameter
|
NULL // Task-Handle (nicht benötigt)
|
||||||
0, // Priorität
|
);
|
||||||
NULL // Task-Handle (nicht benötigt)
|
|
||||||
);
|
|
||||||
//} else {
|
|
||||||
// Serial.println("Not spawning new task, API still active!");
|
|
||||||
// delete params;
|
|
||||||
// return 0;
|
|
||||||
//}
|
|
||||||
|
|
||||||
// Wait for task completion
|
// Wait until foundFilamentId is updated by the API response (not 65535 anymore)
|
||||||
while(spoolmanApiState != API_IDLE) {
|
while (foundFilamentId == 65535) {
|
||||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Additional delay to ensure foundFilamentId is properly set after API state becomes IDLE
|
|
||||||
while (foundFilamentId == NULL) {
|
|
||||||
vTaskDelay(50 / portTICK_PERIOD_MS);
|
vTaskDelay(50 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -902,7 +879,7 @@ uint16_t createSpool(uint16_t vendorId, uint16_t filamentId, JsonDocument& paylo
|
|||||||
// Create new spool in Spoolman database using task system
|
// Create new spool in Spoolman database using task system
|
||||||
// Note: Due to async nature, the ID will be stored in createdSpoolId global variable
|
// Note: Due to async nature, the ID will be stored in createdSpoolId global variable
|
||||||
// Note: This function assumes that the caller has already ensured API is IDLE
|
// Note: This function assumes that the caller has already ensured API is IDLE
|
||||||
createdSpoolId = NULL; // Reset previous value
|
createdSpoolId = 65535; // Reset to invalid value to detect when API response is received
|
||||||
|
|
||||||
String spoolsUrl = spoolmanUrl + apiUrl + "/spool";
|
String spoolsUrl = spoolmanUrl + apiUrl + "/spool";
|
||||||
Serial.print("Create spool with URL: ");
|
Serial.print("Create spool with URL: ");
|
||||||
@@ -956,7 +933,7 @@ uint16_t createSpool(uint16_t vendorId, uint16_t filamentId, JsonDocument& paylo
|
|||||||
|
|
||||||
// Wait for task completion and return the created spool ID
|
// Wait for task completion and return the created spool ID
|
||||||
// Note: createdSpoolId will be set by sendToApi when response is received
|
// Note: createdSpoolId will be set by sendToApi when response is received
|
||||||
while(createdSpoolId == NULL) {
|
while(createdSpoolId == 65535) {
|
||||||
vTaskDelay(50 / portTICK_PERIOD_MS);
|
vTaskDelay(50 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user