fix: add delay to ensure proper setting of vendor and filament IDs after API state changes
This commit is contained in:
@@ -717,6 +717,9 @@ uint16_t checkVendor(String vendor) {
|
|||||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Additional delay to ensure foundVendorId is properly set after API state becomes IDLE
|
||||||
|
vTaskDelay(50 / portTICK_PERIOD_MS);
|
||||||
|
|
||||||
// Check if vendor was found
|
// Check if vendor was found
|
||||||
if (foundVendorId == 0) {
|
if (foundVendorId == 0) {
|
||||||
Serial.println("Vendor not found, creating new vendor...");
|
Serial.println("Vendor not found, creating new vendor...");
|
||||||
@@ -748,7 +751,7 @@ uint16_t createFilament(uint16_t vendorId, const JsonDocument& payload) {
|
|||||||
|
|
||||||
// Create JSON payload for filament creation
|
// Create JSON payload for filament creation
|
||||||
JsonDocument filamentDoc;
|
JsonDocument filamentDoc;
|
||||||
filamentDoc["name"] = payload["name"].as<String>();
|
filamentDoc["name"] = payload["color_name"].as<String>();
|
||||||
filamentDoc["vendor_id"] = String(vendorId);
|
filamentDoc["vendor_id"] = String(vendorId);
|
||||||
filamentDoc["material"] = payload["type"].as<String>();
|
filamentDoc["material"] = payload["type"].as<String>();
|
||||||
filamentDoc["density"] = (payload["density"].is<String>() && payload["density"].as<String>().length() > 0) ? payload["density"].as<String>() : "1.24";
|
filamentDoc["density"] = (payload["density"].is<String>() && payload["density"].as<String>().length() > 0) ? payload["density"].as<String>() : "1.24";
|
||||||
@@ -862,6 +865,9 @@ uint16_t checkFilament(uint16_t vendorId, const JsonDocument& payload) {
|
|||||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Additional delay to ensure foundFilamentId is properly set after API state becomes IDLE
|
||||||
|
vTaskDelay(50 / portTICK_PERIOD_MS);
|
||||||
|
|
||||||
// Check if filament was found
|
// Check if filament was found
|
||||||
if (foundFilamentId == 0) {
|
if (foundFilamentId == 0) {
|
||||||
Serial.println("Filament not found, creating new filament...");
|
Serial.println("Filament not found, creating new filament...");
|
||||||
|
Reference in New Issue
Block a user