Use Moonraker as Klipper API
This commit is contained in:
parent
cbc2becb3b
commit
ce1da350d3
@ -68,7 +68,7 @@ static const t_config_enum_values s_keys_map_PrintHostType {
|
|||||||
{ "prusalink", htPrusaLink },
|
{ "prusalink", htPrusaLink },
|
||||||
{ "prusaconnect", htPrusaConnect },
|
{ "prusaconnect", htPrusaConnect },
|
||||||
{ "octoprint", htOctoPrint },
|
{ "octoprint", htOctoPrint },
|
||||||
{ "mainsail", htMainSail },
|
{ "moonraker", htMoonraker },
|
||||||
{ "duet", htDuet },
|
{ "duet", htDuet },
|
||||||
{ "flashair", htFlashAir },
|
{ "flashair", htFlashAir },
|
||||||
{ "astrobox", htAstroBox },
|
{ "astrobox", htAstroBox },
|
||||||
@ -1953,7 +1953,7 @@ void PrintConfigDef::init_fff_params()
|
|||||||
{ "prusalink", "PrusaLink" },
|
{ "prusalink", "PrusaLink" },
|
||||||
{ "prusaconnect", "PrusaConnect" },
|
{ "prusaconnect", "PrusaConnect" },
|
||||||
{ "octoprint", "OctoPrint" },
|
{ "octoprint", "OctoPrint" },
|
||||||
{ "mainsail", "Mainsail/Fluidd" },
|
{ "moonraker", "Klipper (via Moonraker)" },
|
||||||
{ "duet", "Duet" },
|
{ "duet", "Duet" },
|
||||||
{ "flashair", "FlashAir" },
|
{ "flashair", "FlashAir" },
|
||||||
{ "astrobox", "AstroBox" },
|
{ "astrobox", "AstroBox" },
|
||||||
|
@ -44,7 +44,7 @@ enum class MachineLimitsUsage {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum PrintHostType {
|
enum PrintHostType {
|
||||||
htPrusaLink, htPrusaConnect, htOctoPrint, htMainSail, htDuet, htFlashAir, htAstroBox, htRepetier, htMKS
|
htPrusaLink, htPrusaConnect, htOctoPrint, htMoonraker, htDuet, htFlashAir, htAstroBox, htRepetier, htMKS
|
||||||
};
|
};
|
||||||
|
|
||||||
enum AuthorizationType {
|
enum AuthorizationType {
|
||||||
|
@ -251,8 +251,8 @@ set(SLIC3R_GUI_SOURCES
|
|||||||
Utils/Http.hpp
|
Utils/Http.hpp
|
||||||
Utils/FixModelByWin10.cpp
|
Utils/FixModelByWin10.cpp
|
||||||
Utils/FixModelByWin10.hpp
|
Utils/FixModelByWin10.hpp
|
||||||
Utils/Mainsail.cpp
|
Utils/Moonraker.cpp
|
||||||
Utils/Mainsail.hpp
|
Utils/Moonraker.hpp
|
||||||
Utils/OctoPrint.cpp
|
Utils/OctoPrint.cpp
|
||||||
Utils/OctoPrint.hpp
|
Utils/OctoPrint.hpp
|
||||||
Utils/Duet.cpp
|
Utils/Duet.cpp
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "Mainsail.hpp"
|
#include "Moonraker.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -63,28 +63,28 @@ std::string substitute_host(const std::string& orig_addr, std::string sub_addr)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
Mainsail::Mainsail(DynamicPrintConfig *config) :
|
Moonraker::Moonraker(DynamicPrintConfig *config) :
|
||||||
m_host(config->opt_string("print_host")),
|
m_host(config->opt_string("print_host")),
|
||||||
m_apikey(config->opt_string("printhost_apikey")),
|
m_apikey(config->opt_string("printhost_apikey")),
|
||||||
m_cafile(config->opt_string("printhost_cafile")),
|
m_cafile(config->opt_string("printhost_cafile")),
|
||||||
m_ssl_revoke_best_effort(config->opt_bool("printhost_ssl_ignore_revoke"))
|
m_ssl_revoke_best_effort(config->opt_bool("printhost_ssl_ignore_revoke"))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
const char* Mainsail::get_name() const { return "Mainsail"; }
|
const char* Moonraker::get_name() const { return "Moonraker"; }
|
||||||
|
|
||||||
wxString Mainsail::get_test_ok_msg () const
|
wxString Moonraker::get_test_ok_msg () const
|
||||||
{
|
{
|
||||||
return _(L("Connection to Mainsail works correctly."));
|
return _(L("Connection to Moonraker works correctly."));
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString Mainsail::get_test_failed_msg (wxString &msg) const
|
wxString Moonraker::get_test_failed_msg (wxString &msg) const
|
||||||
{
|
{
|
||||||
return GUI::format_wxstr("%s: %s"
|
return GUI::format_wxstr("%s: %s"
|
||||||
, _L("Could not connect to Mainsail")
|
, _L("Could not connect to Moonraker")
|
||||||
, msg);
|
, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Mainsail::test(wxString& msg) const
|
bool Moonraker::test(wxString& msg) const
|
||||||
{
|
{
|
||||||
// GET /server/info
|
// GET /server/info
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ bool Mainsail::test(wxString& msg) const
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Mainsail::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const
|
bool Moonraker::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const
|
||||||
{
|
{
|
||||||
// POST /server/files/upload
|
// POST /server/files/upload
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ bool Mainsail::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Error
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mainsail::set_auth(Http &http) const
|
void Moonraker::set_auth(Http &http) const
|
||||||
{
|
{
|
||||||
if (!m_apikey.empty())
|
if (!m_apikey.empty())
|
||||||
http.header("X-Api-Key", m_apikey);
|
http.header("X-Api-Key", m_apikey);
|
||||||
@ -240,7 +240,7 @@ void Mainsail::set_auth(Http &http) const
|
|||||||
http.ca_file(m_cafile);
|
http.ca_file(m_cafile);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Mainsail::make_url(const std::string &path) const
|
std::string Moonraker::make_url(const std::string &path) const
|
||||||
{
|
{
|
||||||
if (m_host.find("http://") == 0 || m_host.find("https://") == 0) {
|
if (m_host.find("http://") == 0 || m_host.find("https://") == 0) {
|
||||||
if (m_host.back() == '/') {
|
if (m_host.back() == '/') {
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef slic3r_Mainsail_hpp_
|
#ifndef slic3r_Moonraker_hpp_
|
||||||
#define slic3r_Mainsail_hpp_
|
#define slic3r_Moonraker_hpp_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
@ -16,11 +16,11 @@ class DynamicPrintConfig;
|
|||||||
class Http;
|
class Http;
|
||||||
|
|
||||||
// https://moonraker.readthedocs.io/en/latest/web_api
|
// https://moonraker.readthedocs.io/en/latest/web_api
|
||||||
class Mainsail : public PrintHost
|
class Moonraker : public PrintHost
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Mainsail(DynamicPrintConfig *config);
|
Moonraker(DynamicPrintConfig *config);
|
||||||
~Mainsail() override = default;
|
~Moonraker() override = default;
|
||||||
|
|
||||||
const char* get_name() const override;
|
const char* get_name() const override;
|
||||||
|
|
@ -19,7 +19,7 @@
|
|||||||
#include "AstroBox.hpp"
|
#include "AstroBox.hpp"
|
||||||
#include "Repetier.hpp"
|
#include "Repetier.hpp"
|
||||||
#include "MKS.hpp"
|
#include "MKS.hpp"
|
||||||
#include "Mainsail.hpp"
|
#include "Moonraker.hpp"
|
||||||
#include "../GUI/PrintHostDialogs.hpp"
|
#include "../GUI/PrintHostDialogs.hpp"
|
||||||
|
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
@ -55,7 +55,7 @@ PrintHost* PrintHost::get_print_host(DynamicPrintConfig *config)
|
|||||||
case htPrusaLink: return new PrusaLink(config);
|
case htPrusaLink: return new PrusaLink(config);
|
||||||
case htPrusaConnect: return new PrusaConnect(config);
|
case htPrusaConnect: return new PrusaConnect(config);
|
||||||
case htMKS: return new MKS(config);
|
case htMKS: return new MKS(config);
|
||||||
case htMainSail: return new Mainsail(config);
|
case htMoonraker: return new Moonraker(config);
|
||||||
default: return nullptr;
|
default: return nullptr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user