refactor: unify string conversion functions for LoRaBandwidth and LoRaCodingRate
This commit is contained in:
@ -27,7 +27,7 @@ enum LoRaBandwidth : uint8_t {
|
|||||||
BW_500_0 = 0x06,
|
BW_500_0 = 0x06,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const char *bw_to_string(const LoRaBandwidth &bw) {
|
inline const char *to_str(LoRaBandwidth bw) {
|
||||||
switch (bw) {
|
switch (bw) {
|
||||||
case LoRaBandwidth::BW_7_8:
|
case LoRaBandwidth::BW_7_8:
|
||||||
return "7.8kHz";
|
return "7.8kHz";
|
||||||
@ -61,7 +61,7 @@ enum LoRaCodingRate : uint8_t {
|
|||||||
CR_4_8 = 0x04,
|
CR_4_8 = 0x04,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const char *cr_to_string(const LoRaCodingRate &cr) {
|
inline const char *to_str(LoRaCodingRate cr) {
|
||||||
switch (cr) {
|
switch (cr) {
|
||||||
case LoRaCodingRate::CR_4_5:
|
case LoRaCodingRate::CR_4_5:
|
||||||
return "4/5";
|
return "4/5";
|
||||||
@ -114,9 +114,9 @@ struct modulation_params_t {
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
auto to_string() const -> std::string {
|
auto to_string() const -> std::string {
|
||||||
return std::format("mod_params: bw={}, sf={}, cr={}, ldr_optimize={}",
|
return std::format("mod_params: bw={}, sf={}, cr={}, ldr_optimize={}",
|
||||||
bw_to_string(static_cast<LoRaBandwidth>(bw)),
|
to_str(static_cast<LoRaBandwidth>(bw)),
|
||||||
sf,
|
sf,
|
||||||
cr_to_string(static_cast<LoRaCodingRate>(cr)),
|
to_str(static_cast<LoRaCodingRate>(cr)),
|
||||||
ldr_optimize ? "ON" : "OFF");
|
ldr_optimize ? "ON" : "OFF");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user