Skip to content

Commit 4e5a350

Browse files
committed
add lastEspErr variable to store esp32 camera api return values
In order to get more details on API failure reason, the return error code needs to be stored and evaluated.
1 parent c61dc47 commit 4e5a350

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/esp32cam.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ CameraClass Camera;
1313
bool
1414
CameraClass::begin(const Config& config)
1515
{
16-
return esp_camera_init(reinterpret_cast<const camera_config_t*>(config.m_cfg)) == ESP_OK;
16+
lastEspErr = esp_camera_init(reinterpret_cast<const camera_config_t*>(config.m_cfg));
17+
return (lastEspErr == ESP_OK ? true : false);
1718
}
1819

1920
bool
2021
CameraClass::end()
2122
{
22-
return esp_camera_deinit() == ESP_OK;
23+
lastEspErr = esp_camera_deinit();
24+
return (lastEspErr == ESP_OK ? true : false);
2325
}
2426

2527
bool

src/esp32cam.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ class CameraClass
225225
return streamMjpeg(client, StreamMjpegConfig());
226226
}
227227

228+
/** \brief Return value for esp API calls
229+
* \Store last api return value here useful for error handling!
230+
*/
231+
esp_err_t lastEspErr;
228232

229233
};
230234

0 commit comments

Comments
 (0)