Conversation
Upstream restructured the daemon since this branch forked: ServerInterface was replaced by UploadTarget/Config/LogDatabase, MAVLink FTP replaced the log_files plugin, and tomlplusplus was vendored while nlohmann/json moved to third_party/json. The conflicts are resolved to upstream's tree wholesale. The Meala backend that lived in ServerInterface.hpp/MealaServerInterface.cpp is dropped here and reintroduced on the new UploadTarget architecture in the following commit, which is also where the PR review comments are addressed.
Reimplements the Meala integration on top of the current UploadTarget architecture and addresses the review feedback from PR ARK-Electronics#23. A target now carries a backend ("flight_review" by default, or "meala") and an optional credentials_file. UploadTarget grows a virtual upload() plus protected helpers for the parts every backend shares -- the reachability probe, the 401/403 cooldown, and the local-file checks -- and make_upload_target() builds the one the config names. Backend is per target, so the local Flight Review and the remote server are independent, and since a target is keyed in the database by its name rather than its url, switching backends does not re-upload what is already up. MealaUploadTarget logs in for a session cookie and posts the log in 5 MB Dropzone-style chunks, mapping Meala's replies onto the existing Outcome set so the upload loop's retry, rejection and cooldown handling applies unchanged. The credentials file is read on first login rather than at construction, so one that appears after startup is picked up. A meala target with no credentials_file is disabled at startup with a warning instead of failing a login every upload pass. Review comments addressed: - MealaCredentials and the Meala class live in their own header, not in the base class's. - The unused includes (<optional> and <vector> in the old ServerInterface, the hpp-duplicating include in LogLoader.cpp) are gone; nothing here includes what it does not use. - The commented-out _remote_server line is gone. - README documents the supported backends in a table, with a link to Meala and what each backend needs. Verified against a stub Meala server: login, cookie reuse, and a 12 MB log in three chunks reassembling to a matching sha256, plus the refused-login, no-cookie, rejected-chunk, missing/empty-file, missing/malformed-credentials and unreachable-server paths. Full build with -Werror, ctest and make check-format all pass.
…server Checked the implementation against Meala's OpenAPI spec and a real upload. The endpoints and form fields were already right; three things were not. 202 was treated as a server error. The spec defines it as "upload received; database temporarily unavailable -- will be processed later", so the log is up and re-sending it would have pushed a second copy rather than retried a failed one. It now counts as success alongside 200. The session cookie was sent back verbatim, attributes and all. Only the name=value pair belongs in a Cookie header; an Expires attribute contains a comma, so echoing the rest risks a malformed header. It is now trimmed at the first ";", and an empty cookie is treated as a failed login. A refused login is documented as 400, but Meala actually answers it with 200 and a session cookie -- an unauthenticated session. The first thing to notice was the chunk POST, so bad credentials meant pushing a multi-megabyte body every cooldown just to be told 401. login() now confirms the session with one parameterless call that answers in a few dozen bytes. Only an explicit 401/403 stops the upload: if that endpoint ever moves or errs, the upload proceeds as it did before, so the check cannot become a new way to fail. Verified against https://apisdynamics.ca with a 6.6 MB PX4 log: uploaded in two chunks, accepted, parsed server-side as PX4 with a plausible duration and takeoff time, and downloaded back with a sha256 matching the source byte for byte. Bad credentials now return Unauthorized before any chunk is sent. The stub-server cases still pass, including one where the session-check endpoint is absent and the upload goes through regardless. Full build with -Werror, ctest and make check-format all pass.
comment, battery, pic, gso and vehicle_id were hardcoded in the upload form. They are now read from the upload target's table in config.toml, defaulting to the previous values, so an operator can fill in the aircraft and crew without rebuilding.
Updated comments for clarity in config.toml.
Author
|
Got distracted for a year, but I finally got around to finishing this :) See PR #23 for my previous attempt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added Meala as an additional backend
https://apisdynamics.ca/logs
API docs for Meala:
https://apisdynamics.ca/apidocs/
Tested on ARK Jetson PAB bundle with real flights
Info on using Meala as a backend added to the readme; requires downloading a cert file from the Meala website and pointing to it in config.toml