refactor: unify string conversion functions for LoRaBandwidth and LoRaCodingRate

This commit is contained in:
2025-08-04 15:37:04 +08:00
parent 04efb1e40b
commit 1d31faef01

View File

@ -27,7 +27,7 @@ enum LoRaBandwidth : uint8_t {
BW_500_0 = 0x06,
};
inline const char *bw_to_string(const LoRaBandwidth &bw) {
inline const char *to_str(LoRaBandwidth bw) {
switch (bw) {
case LoRaBandwidth::BW_7_8:
return "7.8kHz";
@ -61,7 +61,7 @@ enum LoRaCodingRate : uint8_t {
CR_4_8 = 0x04,
};
inline const char *cr_to_string(const LoRaCodingRate &cr) {
inline const char *to_str(LoRaCodingRate cr) {
switch (cr) {
case LoRaCodingRate::CR_4_5:
return "4/5";
@ -114,9 +114,9 @@ struct modulation_params_t {
[[nodiscard]]
auto to_string() const -> std::string {
return std::format("mod_params: bw={}, sf={}, cr={}, ldr_optimize={}",
bw_to_string(static_cast<LoRaBandwidth>(bw)),
to_str(static_cast<LoRaBandwidth>(bw)),
sf,
cr_to_string(static_cast<LoRaCodingRate>(cr)),
to_str(static_cast<LoRaCodingRate>(cr)),
ldr_optimize ? "ON" : "OFF");
}
};