bool FlarmDevice::ReadFlightList(RecordedFlightList &flight_list, OperationEnvironment &env) { if (!BinaryMode(env)) return false; // Try to receive flight information until the list is full for (uint8_t i = 0; !flight_list.full(); ++i) { FLARM::MessageType ack_result = SelectFlight(i, env); // Last record reached -> bail out and return list if (ack_result == FLARM::MT_NACK) break; // If neither ACK nor NACK was received if (ack_result != FLARM::MT_ACK || env.IsCancelled()) { mode = Mode::UNKNOWN; return false; } RecordedFlightInfo flight_info; flight_info.internal.flarm = i; if (ReadFlightInfo(flight_info, env)) flight_list.append(flight_info); } return true; }
bool FlarmDevice::DownloadFlight(const RecordedFlightInfo &flight, Path path, OperationEnvironment &env) { if (!BinaryMode(env)) return false; FLARM::MessageType ack_result = SelectFlight(flight.internal.flarm, env); // If no ACK was received -> cancel if (ack_result != FLARM::MT_ACK || env.IsCancelled()) return false; try { if (DownloadFlight(path, env)) return true; } catch (...) { mode = Mode::UNKNOWN; throw; } mode = Mode::UNKNOWN; return false; }