Prusa MINI Firmware overview
|
◆ LAST_MODIFY
#define LAST_MODIFY __TIMESTAMP__ |
◆ BUFFER_RESPONSE_SIZE
#define BUFFER_RESPONSE_SIZE 256 |
◆ State_t
Response state enumeration.
Enumerator |
---|
FIRST | First coroutine_fn call after creation
|
NEXT | Any other coroutine_fn call while all data is not sent
|
DONE | Last coroutine_fn call, coroutine_fn must delete response object
|
◆ api_job()
return coroutine_fn for /api/job request
Function create BufferResponse object, set its pointer to arg and return buffer_coroutine.
213 if (res.get() !=
nullptr) {
215 res->ct_header.value =
"application/json";
218 return std::move(res);
◆ api_printer()
return coroutine_fn for /api/printer request
Function create BufferResponse object, set its pointer to arg and return buffer_coroutine.
228 if (res.get() !=
nullptr) {
230 res->ct_header.value =
"application/json";
232 #ifndef TEST_INTEGRITY
238 float actual_nozzle = 26;
239 float target_nozzle = 32;
240 float actual_heatbed = 55;
241 float target_heatbed = 16;
246 "\"tool0\":{\"actual\":%f, \"target\":%f},"
247 "\"bed\":{\"actual\":%f, \"target\":%f}}}",
248 static_cast<double>(actual_nozzle), static_cast<double>(target_nozzle),
249 static_cast<double>(actual_heatbed), static_cast<double>(target_heatbed));
251 return std::move(res);
◆ api_post()
return 200 OK when file is post right
258 printf(
"Request headers:\n");
259 size_t content_length = 0;
260 for (
auto it =
env.get_headers(); it !=
nullptr; it = it->next) {
264 if (!strcmp(it->key,
"Content-Length")) {
265 content_length = dynamic_cast<const NumberHeader *>(it)->value;
269 std::unique_ptr<WaitResponse> res(
new WaitResponse(content_length));
◆ not_found()
return coroutine_fn for Not Found response
Function create BufferResponse object, set its pointer to arg and return buffer_coroutine.
279 if (res.get() !=
nullptr) {
281 res->ct_header.value =
"text/plain";
283 res->printf(
"Not Found");
◆ request_header()
IHeader* request_header |
( |
const char * |
key, |
|
|
size_t |
key_length, |
|
|
const char * |
value, |
|
|
size_t |
value_length |
|
) |
| |
request_header_fn callbacke, which is call from LwIP WSAPI http server
292 if (!std::strncmp(
req_headers[
i].key, key, key_length)) {
◆ application()
application_fn callback, which is called from LwIP WSAPI http server
Define of application functions.
- Parameters
-
env | request environment defined in lwsapi.h |
arg | pointer to pointer to internal application reqeust object. This pointer is argument of coroutine_fn funtcions. |
- Returns
- coroutine_fn for response
308 _dbg(
"HTTP Request: %s %s",
env.method,
env.request_uri);
310 if (!strcmp(
env.method,
"GET") || !strcmp(
env.method,
"HEAD")) {
318 if (!strcmp(
env.request_uri,
"/api/job")) {
320 }
else if (!strcmp(
env.request_uri,
"/api/printer")) {
323 }
else if (!strcmp(
env.method,
"POST")) {
324 if (!strcmp(
env.request_uri,
"/post")) {
◆ req_headers
◆ files
Initial value:
Array of files which could be responed by http.
IResponse::unique_ptr_t api_job(Environment &env)
return coroutine_fn for /api/job request
Definition: connect.cpp:211
const uint8_t status_heatbed_svg[]
Definition: status_heatbed_svg.c:3
static FORCE_INLINE int16_t degTargetHotend(const uint8_t E_NAME)
Definition: temperature.h:562
const uint8_t index_js[]
Definition: index_js.c:3
const char * HTTP_404
Definition: http_states.c:5
const uint8_t status_filament_svg[]
Definition: status_filament_svg.c:3
const uint8_t favicon_ico[]
Definition: favicon_ico.c:3
IResponse::unique_ptr_t not_found(Environment &env)
return coroutine_fn for Not Found response
Definition: connect.cpp:277
static const FileHandler_t files[]
Array of files which could be responed by http.
Definition: connect.cpp:52
IResponse::unique_ptr_t api_post(Environment &env)
return 200 OK when file is post right
Definition: connect.cpp:257
IHeader * number_header_factory(const char *key, const char *value, size_t value_length)
Response new NumberHeader.
Definition: lwsapi.cpp:445
Class to response any static files defined in files array.
Definition: connect.cpp:84
uint8_t i
Definition: screen_test_graph.c:72
const uint8_t status_prnspeed_svg[]
Definition: status_prnspeed_svg.c:3
static FORCE_INLINE float degHotend(const uint8_t E_NAME)
Definition: temperature.h:544
Definition: connect.cpp:77
IHeader * dynamics_header_factory(const char *key, const char *value, size_t value_length)
Return new DynamicsHeader.
Definition: lwsapi.cpp:440
Definition: connect.cpp:78
const uint8_t status_nozzle_svg[]
Definition: status_nozzle_svg.c:3
const header_factory_t req_headers[]
Definition: connect.cpp:37
const uint8_t status_prnflow_svg[]
Definition: status_prnflow_svg.c:3
const uint8_t under_construction_gif[]
Definition: under_construction_gif.c:3
Definition: connect.cpp:79
env
Definition: create_custom_upload_command_CDC.py:23
const char * HTTP_200
Definition: http_states.c:3
#define _dbg(...)
Definition: dbg.h:50
const uint8_t index_css[]
Definition: index_css.c:3
const char * file_name
Definition: connect.cpp:45
const uint8_t index_html[]
Definition: index_html.c:3
File handler structure.
Definition: connect.cpp:44
Universal response class with internal buffer size by BUFFER_RESPONSE_SIZE.
Definition: connect.cpp:119
const uint8_t connect_black_svg[]
Definition: connect_black_svg.c:3
Definition: connect.cpp:157
const uint8_t status_z_axis_svg[]
Definition: status_z_axis_svg.c:3
Temperature thermalManager
Definition: temperature.cpp:89
IResponse::unique_ptr_t api_printer(Environment &env)
return coroutine_fn for /api/printer request
Definition: connect.cpp:226