feat: enhance error handling and logging in calibration functions
This commit is contained in:
@ -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 ¶ms) -> 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();
|
||||
{
|
||||
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 ¶ms) -> Result<Unit
|
||||
|
||||
#ifndef APP_RADIO_DISABLE_CALIBRATION
|
||||
res = calibrate_image(params.frequency);
|
||||
{
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user