feat: enhance error handling and logging in calibration functions

This commit is contained in:
2025-08-12 12:10:04 +08:00
parent 5d629415f6
commit d80eeb7c3f

View File

@ -11,6 +11,7 @@
#include <cstring>
#include <optional>
#include <esp_log.h>
#include "esp_log_level.h"
#include "hal/gpio_types.h"
#include "hal_gpio.hpp"
#include "app_const_llcc68.hpp"
@ -1308,16 +1309,27 @@ static constexpr auto begin = [](const lora_parameters_t &params) -> Result<Unit
res = set_packet_type_lora(mod_params.sf);
APP_RADIO_RETURN_ERR_CTX(res, "config packet type");
res = get_device_error_print_and_clear(TAG);
APP_RADIO_RETURN_ERR_CTX(res, "get device error");
#ifndef APP_RADIO_DISABLE_CALIBRATION
res = calibrate();
APP_RADIO_RETURN_ERR_CTX(res, "calibrate");
{
constexpr auto TAG = "calibrate";
if (not res) {
ESP_LOGE(TAG, "%d", res.error());
res = get_device_error_print_and_clear(TAG);
APP_RADIO_RETURN_ERR_CTX(res, "calibrate");
} else {
ESP_LOGI(TAG, "ok");
}
}
#endif /* APP_RADIO_DISABLE_CALIBRATION */
res = set_modulation_params(mod_params.sf,
mod_params.bw,
mod_params.cr,
mod_params.ldr_optimize);
res = get_device_error_print_and_clear(TAG);
APP_RADIO_RETURN_ERR_CTX(res, "set modulation params");
res = set_lora_sync_word(params.sync_word);
@ -1337,8 +1349,16 @@ static constexpr auto begin = [](const lora_parameters_t &params) -> Result<Unit
#ifndef APP_RADIO_DISABLE_CALIBRATION
res = calibrate_image(params.frequency);
res = get_device_error_print_and_clear(TAG);
APP_RADIO_RETURN_ERR_CTX(res, "calibrate image");
{
constexpr auto TAG = "calibrate_image";
if (not res) {
ESP_LOGE(TAG, "%d", res.error());
res = get_device_error_print_and_clear(TAG);
APP_RADIO_RETURN_ERR_CTX(res, "calibrate image");
} else {
ESP_LOGI(TAG, "ok");
}
}
#endif /* APP_RADIO_DISABLE_CALIBRATION */
res = set_packet_params(packet_params.preamble_len,