added test parts of the code for various errors
parent
41f32f7033
commit
49f89e94fd
|
|
@ -277,6 +277,7 @@ void Camera::CapturePhoto() {
|
||||||
log->AddEvent(LogLevel_Info, F("Taking photo..."));
|
log->AddEvent(LogLevel_Info, F("Taking photo..."));
|
||||||
|
|
||||||
/* capture final photo */
|
/* capture final photo */
|
||||||
|
delay(5); // delay for camera stabilization. test it
|
||||||
FrameBuffer = esp_camera_fb_get();
|
FrameBuffer = esp_camera_fb_get();
|
||||||
if (!FrameBuffer) {
|
if (!FrameBuffer) {
|
||||||
log->AddEvent(LogLevel_Error, F("Camera capture failed! photo"));
|
log->AddEvent(LogLevel_Error, F("Camera capture failed! photo"));
|
||||||
|
|
@ -476,7 +477,8 @@ void Camera::CopyPhoto(String* i_data, int i_from, int i_to) {
|
||||||
* @return int - photo size
|
* @return int - photo size
|
||||||
*/
|
*/
|
||||||
int Camera::GetPhotoSize() {
|
int Camera::GetPhotoSize() {
|
||||||
return FrameBuffer->len;
|
log->AddEvent(LogLevel_Verbose, "Photo size: " + String(FrameBuffer->len));
|
||||||
|
return (int) FrameBuffer->len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,13 @@ void Configuration::GetFingerprint() {
|
||||||
*/
|
*/
|
||||||
void Configuration::SaveUint8(uint16_t address, uint8_t data) {
|
void Configuration::SaveUint8(uint16_t address, uint8_t data) {
|
||||||
EEPROM.write(address, data);
|
EEPROM.write(address, data);
|
||||||
EEPROM.commit();
|
|
||||||
|
if (EEPROM.commit()) {
|
||||||
|
Log->AddEvent(LogLevel_Verbose, F("Write uint8_t done"));
|
||||||
|
} else {
|
||||||
|
Log->AddEvent(LogLevel_Error, F("Failed to write uint8_t"));
|
||||||
|
EEPROM.commit(); // try again
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@info Function for save int8_t to EEPROM
|
@info Function for save int8_t to EEPROM
|
||||||
|
|
@ -268,7 +274,13 @@ void Configuration::SaveUint8(uint16_t address, uint8_t data) {
|
||||||
*/
|
*/
|
||||||
void Configuration::SaveInt8(uint16_t address, int8_t data) {
|
void Configuration::SaveInt8(uint16_t address, int8_t data) {
|
||||||
EEPROM.write(address, data);
|
EEPROM.write(address, data);
|
||||||
EEPROM.commit();
|
|
||||||
|
if (EEPROM.commit()) {
|
||||||
|
Log->AddEvent(LogLevel_Verbose, F("Write int8_t done"));
|
||||||
|
} else {
|
||||||
|
Log->AddEvent(LogLevel_Error, F("Failed to write int8_t"));
|
||||||
|
EEPROM.commit(); // try again
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@info Function for save bool to EEPROM
|
@info Function for save bool to EEPROM
|
||||||
|
|
@ -278,7 +290,13 @@ void Configuration::SaveInt8(uint16_t address, int8_t data) {
|
||||||
*/
|
*/
|
||||||
void Configuration::SaveBool(uint16_t address, bool data) {
|
void Configuration::SaveBool(uint16_t address, bool data) {
|
||||||
EEPROM.write(address, data);
|
EEPROM.write(address, data);
|
||||||
EEPROM.commit();
|
|
||||||
|
if (EEPROM.commit()) {
|
||||||
|
Log->AddEvent(LogLevel_Verbose, F("Write bool done"));
|
||||||
|
} else {
|
||||||
|
Log->AddEvent(LogLevel_Error, F("Failed to write bool"));
|
||||||
|
EEPROM.commit(); // try again
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@info Function for save uint16_t to EEPROM
|
@info Function for save uint16_t to EEPROM
|
||||||
|
|
@ -292,7 +310,13 @@ void Configuration::SaveUint16(uint16_t address, uint16_t data) {
|
||||||
|
|
||||||
EEPROM.write(address, highByte);
|
EEPROM.write(address, highByte);
|
||||||
EEPROM.write(address + 1, lowByte);
|
EEPROM.write(address + 1, lowByte);
|
||||||
EEPROM.commit();
|
|
||||||
|
if (EEPROM.commit()) {
|
||||||
|
Log->AddEvent(LogLevel_Verbose, F("Write uint16_t done"));
|
||||||
|
} else {
|
||||||
|
Log->AddEvent(LogLevel_Error, F("Failed to write uint16_t"));
|
||||||
|
EEPROM.commit(); // try again
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -311,8 +335,13 @@ void Configuration::SaveString(uint16_t address, uint16_t max_length, String dat
|
||||||
for (uint16_t i = address + 1, j = 0; j < data.length(); i++, j++) {
|
for (uint16_t i = address + 1, j = 0; j < data.length(); i++, j++) {
|
||||||
EEPROM.write(i, data.charAt(j));
|
EEPROM.write(i, data.charAt(j));
|
||||||
}
|
}
|
||||||
EEPROM.commit();
|
|
||||||
Log->AddEvent(LogLevel_Verbose, F("Write string done"));
|
if (EEPROM.commit()) {
|
||||||
|
Log->AddEvent(LogLevel_Verbose, F("Write string done"));
|
||||||
|
} else {
|
||||||
|
Log->AddEvent(LogLevel_Error, F("Failed to write string"));
|
||||||
|
EEPROM.commit(); // try again
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Log->AddEvent(LogLevel_Verbose, F("Skip write string"));
|
Log->AddEvent(LogLevel_Verbose, F("Skip write string"));
|
||||||
}
|
}
|
||||||
|
|
@ -331,7 +360,12 @@ void Configuration::SaveIpAddress(uint16_t address, String data) {
|
||||||
EEPROM.write(address + 1, ip[1]);
|
EEPROM.write(address + 1, ip[1]);
|
||||||
EEPROM.write(address + 2, ip[2]);
|
EEPROM.write(address + 2, ip[2]);
|
||||||
EEPROM.write(address + 3, ip[3]);
|
EEPROM.write(address + 3, ip[3]);
|
||||||
EEPROM.commit();
|
|
||||||
|
if (EEPROM.commit()) {
|
||||||
|
Log->AddEvent(LogLevel_Verbose, F("Write IP address done"));
|
||||||
|
} else {
|
||||||
|
Log->AddEvent(LogLevel_Error, F("Failed to write IP address"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ bool PrusaConnect::SendDataToBackend(String *i_data, int i_data_length, String i
|
||||||
WiFiClientSecure client;
|
WiFiClientSecure client;
|
||||||
BackendReceivedStatus = "";
|
BackendReceivedStatus = "";
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
log->AddEvent(LogLevel_Info, "Sending " + i_type + " to PrusaConnect");
|
log->AddEvent(LogLevel_Info, "Sending " + i_type + " to PrusaConnect, " + String(i_data_length) + " bytes");
|
||||||
|
|
||||||
/* check fingerprint and token length */
|
/* check fingerprint and token length */
|
||||||
if ((Fingerprint.length() > 0) && (Token.length() > 0)) {
|
if ((Fingerprint.length() > 0) && (Token.length() > 0)) {
|
||||||
|
|
@ -119,7 +119,7 @@ bool PrusaConnect::SendDataToBackend(String *i_data, int i_data_length, String i
|
||||||
log->AddEvent(LogLevel_Verbose, F("Send data photo"));
|
log->AddEvent(LogLevel_Verbose, F("Send data photo"));
|
||||||
int index = 0;
|
int index = 0;
|
||||||
/* send data in fragments */
|
/* send data in fragments */
|
||||||
for (index = 0; index < i_data_length; index = index + PHOTO_FRAGMENT_SIZE) {
|
for (index = 0; index < i_data_length; index += PHOTO_FRAGMENT_SIZE) {
|
||||||
camera->CopyPhoto(i_data, index, index + PHOTO_FRAGMENT_SIZE);
|
camera->CopyPhoto(i_data, index, index + PHOTO_FRAGMENT_SIZE);
|
||||||
client.print(*i_data);
|
client.print(*i_data);
|
||||||
log->AddEvent(LogLevel_Verbose, String(i_data_length) + "/" + String(index));
|
log->AddEvent(LogLevel_Verbose, String(i_data_length) + "/" + String(index));
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ private:
|
||||||
Logs *log; ///< pointer to logs object
|
Logs *log; ///< pointer to logs object
|
||||||
Camera *camera; ///< pointer to camera object
|
Camera *camera; ///< pointer to camera object
|
||||||
|
|
||||||
bool SendDataToBackend(String *,int, String, String, String, SendDataToBackendType);
|
bool SendDataToBackend(String *, int, String, String, String, SendDataToBackendType);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PrusaConnect(Configuration*, Logs*, Camera*);
|
PrusaConnect(Configuration*, Logs*, Camera*);
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,7 @@ String Logs::GetSystemTime() {
|
||||||
struct tm timeinfo;
|
struct tm timeinfo;
|
||||||
if (!getLocalTime(&timeinfo)) {
|
if (!getLocalTime(&timeinfo)) {
|
||||||
#if (true == CONSOLE_VERBOSE_DEBUG)
|
#if (true == CONSOLE_VERBOSE_DEBUG)
|
||||||
Serial.println("Failed to obtain time");
|
Serial.println(F("Failed to obtain time"));
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ String lastTwoChars = command.substring(command.length() - 2);
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
|
|
||||||
} else if (command.startsWith("commandslist") && command.endsWith(";")) {
|
} else if (command.startsWith("commandslist") && command.endsWith(";")) {
|
||||||
log->AddEvent(LogLevel_Warning, "--> Available commands");
|
log->AddEvent(LogLevel_Warning, F("--> Available commands"));
|
||||||
PrintAvailableCommands();
|
PrintAvailableCommands();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue