jfjoch_viewer: Add more mask functionality

This commit is contained in:
2025-11-05 14:38:48 +01:00
parent d793520d39
commit 1f97131d45
11 changed files with 212 additions and 4 deletions

View File

@@ -199,3 +199,33 @@ std::vector<float> JFJochHttpReader::GetPlot_i(const std::string &plot_type, flo
"Could not parse image buffer status");
}
}
void JFJochHttpReader::UploadUserMask(const std::vector<uint32_t>& mask) {
std::unique_lock ul(http_mutex);
if (addr.empty())
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"HTTP address not set. Call ReadURL() first.");
if (mask.empty())
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"User mask is empty.");
httplib::Client cli_cmd(addr);
const char* data_ptr = reinterpret_cast<const char*>(mask.data());
const size_t byte_size = mask.size() * sizeof(uint32_t);
auto res = cli_cmd.Put("/config/user_mask",
data_ptr,
byte_size,
"application/octet-stream");
if (!res)
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"Failed to connect to server to upload user mask");
if (res->status != httplib::StatusCode::OK_200)
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"Server rejected user mask upload");
}