| 202 | } |
| 203 | |
| 204 | std::vector<openhd::Setting> AirTelemetry::get_all_settings() { |
| 205 | std::vector<openhd::Setting> ret{}; |
| 206 | using namespace openhd::telemetry; |
| 207 | auto c_fc_uart_connection_type = [this](std::string, std::string value) { |
| 208 | // We just accept anything |
| 209 | m_air_settings->unsafe_get_settings().fc_uart_connection_type = value; |
| 210 | m_air_settings->persist(); |
| 211 | setup_uart(); |
| 212 | return true; |
| 213 | }; |
| 214 | auto c_fc_uart_baudrate = [this](std::string, int value) { |
| 215 | if (!SerialEndpoint::is_valid_linux_baudrate(value)) return false; |
| 216 | m_air_settings->unsafe_get_settings().fc_uart_baudrate = value; |
| 217 | m_air_settings->persist(); |
| 218 | setup_uart(); |
| 219 | return true; |
| 220 | }; |
| 221 | auto c_fc_uart_flow_control = [this](std::string, int value) { |
| 222 | if (!openhd::validate_yes_or_no(value)) { |
| 223 | return false; |
| 224 | } |
| 225 | m_air_settings->unsafe_get_settings().fc_uart_flow_control = value; |
| 226 | m_air_settings->persist(); |
| 227 | setup_uart(); |
| 228 | return true; |
| 229 | }; |
| 230 | auto c_fc_battery_n_cells = [this](std::string, int value) { |
| 231 | if (value < 0) return false; |
| 232 | m_air_settings->unsafe_get_settings().fc_battery_n_cells = value; |
| 233 | m_air_settings->persist(false); |
| 234 | return true; |
| 235 | }; |
| 236 | ret.push_back(openhd::Setting{ |
| 237 | air::FC_UART_CONNECTION_TYPE, |
| 238 | openhd::StringSetting{ |
| 239 | m_air_settings->get_settings().fc_uart_connection_type, |
| 240 | c_fc_uart_connection_type}}); |
| 241 | ret.push_back(openhd::Setting{ |
| 242 | air::FC_UART_BAUD_RATE, |
| 243 | openhd::IntSetting{ |
| 244 | static_cast<int>(m_air_settings->get_settings().fc_uart_baudrate), |
| 245 | c_fc_uart_baudrate}}); |
| 246 | ret.push_back(openhd::Setting{ |
| 247 | air::FC_UART_FLOW_CONTROL, |
| 248 | openhd::IntSetting{ |
| 249 | static_cast<int>(m_air_settings->get_settings().fc_uart_flow_control), |
| 250 | c_fc_uart_flow_control}}); |
| 251 | ret.push_back(openhd::Setting{ |
| 252 | air::FC_BATT_N_CELLS, |
| 253 | openhd::IntSetting{ |
| 254 | static_cast<int>(m_air_settings->get_settings().fc_battery_n_cells), |
| 255 | c_fc_battery_n_cells}}); |
| 256 | // and this allows an advanced user to change its air unit to a ground unit |
| 257 | // only expose this setting if OpenHD uses the file workaround to figure out |
| 258 | // air or ground. |
| 259 | if (openhd::tmp::file_air_or_ground_exists()) { |
| 260 | auto c_config_boot_as_air = [](std::string, int value) { |
| 261 | return openhd::tmp::handle_telemetry_change(value); |
nothing calls this directly
no test coverage detected