improve stability
This commit is contained in:
@ -30,6 +30,9 @@ static sMetric aMetrics[METRIC_MAX_COUNT];
|
||||
static uint16_t u16MetricCounter = 0U;
|
||||
|
||||
void taskMetrics(void *pvParameters);
|
||||
void connect_wifi(void);
|
||||
httpd_handle_t setup_server(void);
|
||||
esp_err_t get_metrics_handler(httpd_req_t *req);
|
||||
|
||||
void initMetrics(void)
|
||||
{
|
||||
@ -39,7 +42,7 @@ void initMetrics(void)
|
||||
BaseType_t taskCreated = xTaskCreate(
|
||||
taskMetrics, // Function to implement the task
|
||||
"taskMetrics", // Task name
|
||||
2048, // Stack size (in words, not bytes)
|
||||
4096, // Stack size (in words, not bytes)
|
||||
NULL, // Parameters to the task function (none in this case)
|
||||
5, // Task priority (higher number = higher priority)
|
||||
NULL // Task handle (optional)
|
||||
@ -268,24 +271,22 @@ esp_err_t get_metrics_handler(httpd_req_t *req)
|
||||
}
|
||||
}
|
||||
|
||||
httpd_uri_t uri_get = {
|
||||
.uri = "/metrics",
|
||||
.method = HTTP_GET,
|
||||
.handler = get_metrics_handler,
|
||||
.user_ctx = NULL};
|
||||
|
||||
httpd_handle_t setup_server(void)
|
||||
{
|
||||
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
|
||||
config.server_port = 9100;
|
||||
httpd_handle_t server = NULL;
|
||||
|
||||
httpd_uri_t uri_get = {
|
||||
.uri = "/metrics",
|
||||
.method = HTTP_GET,
|
||||
.handler = get_metrics_handler,
|
||||
.user_ctx = NULL};
|
||||
|
||||
xMutexAccessMetricResponse = xSemaphoreCreateBinary();
|
||||
if (xMutexAccessMetricResponse == NULL)
|
||||
{
|
||||
ESP_LOGE(TAG, "Unable to create mutex for metric response");
|
||||
vTaskDelay(pdMS_TO_TICKS(300 * 60)); // wait 5min before restart
|
||||
esp_restart();
|
||||
}
|
||||
xSemaphoreGive(xMutexAccessMetricResponse);
|
||||
|
||||
|
Reference in New Issue
Block a user