forked from Akcelerometry_drgania_WMT/PI_mikrokontroler
Usuniecie logow DEBUG z APIClient, UploadManager i main
This commit is contained in:
@@ -71,7 +71,6 @@ bool APIClient::uploadMeasurement(const String &filePath) {
|
|||||||
|
|
||||||
// Multipart body: head + file data + tail
|
// Multipart body: head + file data + tail
|
||||||
client.print(head);
|
client.print(head);
|
||||||
ESP_LOGI(TAG_API, "DEBUG: Beginning file read loop");
|
|
||||||
|
|
||||||
uint8_t buffer[2048];
|
uint8_t buffer[2048];
|
||||||
while (file.available()) {
|
while (file.available()) {
|
||||||
@@ -80,10 +79,8 @@ bool APIClient::uploadMeasurement(const String &filePath) {
|
|||||||
Watchdog::feed();
|
Watchdog::feed();
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGI(TAG_API, "DEBUG: File read loop finished. Writing tail.");
|
|
||||||
client.print(tail);
|
client.print(tail);
|
||||||
file.close();
|
file.close();
|
||||||
ESP_LOGI(TAG_API, "DEBUG: Tail written. Waiting for response...");
|
|
||||||
|
|
||||||
// --- Parsowanie odpowiedzi ---
|
// --- Parsowanie odpowiedzi ---
|
||||||
int httpCode = 0;
|
int httpCode = 0;
|
||||||
@@ -101,7 +98,6 @@ bool APIClient::uploadMeasurement(const String &filePath) {
|
|||||||
}
|
}
|
||||||
Watchdog::feed();
|
Watchdog::feed();
|
||||||
}
|
}
|
||||||
ESP_LOGI(TAG_API, "DEBUG: Header parsing loop finished. httpCode: %d", httpCode);
|
|
||||||
|
|
||||||
String responseBody = "";
|
String responseBody = "";
|
||||||
while (client.available()) {
|
while (client.available()) {
|
||||||
|
|||||||
@@ -63,9 +63,7 @@ void UploadManager::uploadFile(const String& filePath) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGI(TAG_UPLOAD, "DEBUG: Before apiClient.uploadMeasurement");
|
|
||||||
bool success = apiClient.uploadMeasurement(filePath);
|
bool success = apiClient.uploadMeasurement(filePath);
|
||||||
ESP_LOGI(TAG_UPLOAD, "DEBUG: After apiClient.uploadMeasurement. Success: %d", success);
|
|
||||||
if (success) {
|
if (success) {
|
||||||
appendLog(filePath, "OK");
|
appendLog(filePath, "OK");
|
||||||
} else {
|
} else {
|
||||||
@@ -88,14 +86,11 @@ void UploadManager::processPendingUploads() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGI(TAG_UPLOAD, "Checking for pending uploads...");
|
ESP_LOGI(TAG_UPLOAD, "Checking for pending uploads...");
|
||||||
ESP_LOGI(TAG_UPLOAD, "DEBUG: findHighestNumericDir()");
|
|
||||||
uint32_t highestDir = capture_.findHighestNumericDir();
|
uint32_t highestDir = capture_.findHighestNumericDir();
|
||||||
ESP_LOGI(TAG_UPLOAD, "DEBUG: highestDir: %u", highestDir);
|
|
||||||
if (highestDir == 0) return;
|
if (highestDir == 0) return;
|
||||||
|
|
||||||
for (uint32_t d = 1; d <= highestDir; d++) {
|
for (uint32_t d = 1; d <= highestDir; d++) {
|
||||||
String path = capture_.dirPath(d);
|
String path = capture_.dirPath(d);
|
||||||
ESP_LOGI(TAG_UPLOAD, "DEBUG: Scanning dir: %s", path.c_str());
|
|
||||||
File dir = SD.open(path);
|
File dir = SD.open(path);
|
||||||
if (!dir || !dir.isDirectory()) {
|
if (!dir || !dir.isDirectory()) {
|
||||||
if(dir) dir.close();
|
if(dir) dir.close();
|
||||||
@@ -112,9 +107,7 @@ void UploadManager::processPendingUploads() {
|
|||||||
if (childPath.endsWith(".wmt")) {
|
if (childPath.endsWith(".wmt")) {
|
||||||
if (!isAlreadyUploaded(childPath)) {
|
if (!isAlreadyUploaded(childPath)) {
|
||||||
ESP_LOGI(TAG_UPLOAD, "Found pending file: %s", childPath.c_str());
|
ESP_LOGI(TAG_UPLOAD, "Found pending file: %s", childPath.c_str());
|
||||||
ESP_LOGI(TAG_UPLOAD, "DEBUG: Calling uploadFile()");
|
|
||||||
uploadFile(childPath);
|
uploadFile(childPath);
|
||||||
ESP_LOGI(TAG_UPLOAD, "DEBUG: Finished uploadFile(), delaying 1000ms");
|
|
||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
13
src/main.cpp
13
src/main.cpp
@@ -55,7 +55,6 @@ Thread wifiTestThread = Thread(); // Cykliczny test WiFi
|
|||||||
Thread offlineThread = Thread(); // Jeśli offline
|
Thread offlineThread = Thread(); // Jeśli offline
|
||||||
Thread measureThread = Thread(); // Pomiar i zapis na SD
|
Thread measureThread = Thread(); // Pomiar i zapis na SD
|
||||||
Thread uploadThread = Thread(); // Background upload
|
Thread uploadThread = Thread(); // Background upload
|
||||||
Thread configSyncThread = Thread(); // Polling WiFi config z API
|
|
||||||
|
|
||||||
//////// PROTOTYPY /////////////////
|
//////// PROTOTYPY /////////////////
|
||||||
void setup();
|
void setup();
|
||||||
@@ -230,9 +229,6 @@ void setup() {
|
|||||||
if(config.connect){
|
if(config.connect){
|
||||||
uploadThread.onRun([]() { uploadManager.processPendingUploads(); });
|
uploadThread.onRun([]() { uploadManager.processPendingUploads(); });
|
||||||
uploadThread.setInterval(60000); // Co 1 minutę sprawdzaj zaległe
|
uploadThread.setInterval(60000); // Co 1 minutę sprawdzaj zaległe
|
||||||
|
|
||||||
configSyncThread.onRun([]() { apiClient.fetchWiFiConfig(); });
|
|
||||||
configSyncThread.setInterval(60000); // Odpytywanie o WiFi też co minutę
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dodanie taska loop do WDT
|
// Dodanie taska loop do WDT
|
||||||
@@ -354,7 +350,6 @@ void measure(){
|
|||||||
Watchdog::feed();
|
Watchdog::feed();
|
||||||
if(!capture.isExit){
|
if(!capture.isExit){
|
||||||
capture.printLastFileInfoSerial();
|
capture.printLastFileInfoSerial();
|
||||||
ESP_LOGI(TAG_MAIN, "DEBUG: before readHeaderAndPrint");
|
|
||||||
capture.readHeaderAndPrint(capture.generateNextFilename().c_str());
|
capture.readHeaderAndPrint(capture.generateNextFilename().c_str());
|
||||||
ESP_LOGI(TAG_MAIN, "MEASURE FINISH");
|
ESP_LOGI(TAG_MAIN, "MEASURE FINISH");
|
||||||
} else {
|
} else {
|
||||||
@@ -362,12 +357,9 @@ void measure(){
|
|||||||
//runMeasure = false;
|
//runMeasure = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGI(TAG_MAIN, "DEBUG: Checking WiFi status for upload");
|
|
||||||
if (config.connect && WiFi.status() == WL_CONNECTED) {
|
if (config.connect && WiFi.status() == WL_CONNECTED) {
|
||||||
ESP_LOGI(TAG_MAIN, "TRIGGER UPLOAD PENDING...");
|
ESP_LOGI(TAG_MAIN, "TRIGGER UPLOAD PENDING...");
|
||||||
ESP_LOGI(TAG_MAIN, "DEBUG: Before uploadManager.processPendingUploads()");
|
|
||||||
uploadManager.processPendingUploads();
|
uploadManager.processPendingUploads();
|
||||||
ESP_LOGI(TAG_MAIN, "DEBUG: After uploadManager.processPendingUploads()");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
runMeasure = false;
|
runMeasure = false;
|
||||||
@@ -456,8 +448,9 @@ void loop() {
|
|||||||
|
|
||||||
if(config.connect){
|
if(config.connect){
|
||||||
uploadThread.run();
|
uploadThread.run();
|
||||||
configSyncThread.run();
|
}
|
||||||
} if(offlineThread.shouldRun() && (!config.connect)){
|
|
||||||
|
if(offlineThread.shouldRun() && (!config.connect)){
|
||||||
offlineThread.run();
|
offlineThread.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user