Prusa MINI Firmware overview
WaitResponse Class Reference
Inheritance diagram for WaitResponse:
Collaboration diagram for WaitResponse:

Public Member Functions

 WaitResponse (size_t request_length)
 
virtual Message_t generator (const struct pbuf *input=nullptr) override
 WSAPI generator (called more time from WSAPI http server). More...
 
- Public Member Functions inherited from IResponse
 IResponse (const IResponse &)=delete
 
 IResponse ()
 
- Public Member Functions inherited from LwIPClass
virtual ~LwIPClass ()
 

Public Attributes

size_t done
 
size_t request_length
 
bool close
 

Additional Inherited Members

- Public Types inherited from IResponse
typedef std::unique_ptr< IResponseunique_ptr_t
 
- Static Public Member Functions inherited from LwIPClass
static voidoperator new (size_t size)
 
static void operator delete (void *ptr)
 

Constructor & Destructor Documentation

◆ WaitResponse()

WaitResponse::WaitResponse ( size_t  request_length)
164  : done(0)
166  , close(false) {}

Member Function Documentation

◆ generator()

virtual Message_t WaitResponse::generator ( const struct pbuf input = nullptr)
overridevirtual

WSAPI generator (called more time from WSAPI http server).

This is generator method must iterative return response content.

Parameters
inputis LwIP input buffer chain.
Returns
Message contains response, headers, payload and length. If length is EOF, all data was sent. Response must be set in first time, headers second time and payload could be send moretimes. When response or headers in message exists, that will be send. All data in message must exists to next generator call!

Implements IResponse.

168  {
169  for (auto it = input; it != nullptr; it = it->next) {
170  for (size_t i = 0; i < it->len; i++) {
171  // process data
172  // printf("%c", ((char*)(it->payload))[i]);
173  }
174  done += it->len;
175  }
176 
177  if (close) {
178  return (Message_t) { nullptr, nullptr, nullptr, EOF };
179  }
180  if (done == request_length) {
181  close = true;
182  return (Message_t) { HTTP_200, nullptr, nullptr, 0 };
183  }
184 
185  // not readed
186  return (Message_t) { nullptr, nullptr, nullptr, 0 };
187  }

Member Data Documentation

◆ done

size_t WaitResponse::done

◆ request_length

size_t WaitResponse::request_length

◆ close

bool WaitResponse::close
WaitResponse::done
size_t done
Definition: connect.cpp:159
i
uint8_t i
Definition: screen_test_graph.c:72
HTTP_200
const char * HTTP_200
Definition: http_states.c:3
Message_t
Message which must be returned from coroutine generator.
Definition: lwsapi_app.hpp:211
WaitResponse::close
bool close
Definition: connect.cpp:161
EOF
#define EOF
Definition: ff.h:286
WaitResponse::request_length
size_t request_length
Definition: connect.cpp:160