Prusa MINI Firmware overview
BufferResponse Class Reference

Universal response class with internal buffer size by BUFFER_RESPONSE_SIZE. More...

Inheritance diagram for BufferResponse:
Collaboration diagram for BufferResponse:

Public Member Functions

 BufferResponse ()
 
int printf (const char *format...)
 write string data to internal buffer More...
 
const uint8_tbuffer () const
 return internal string buffer as array of bytes More...
 
int length () const
 return length of internal string buffer More...
 
virtual Message_t generator (const struct pbuf *input=nullptr) override
 Response generator, iterative returns file data. More...
 
- Public Member Functions inherited from IResponse
 IResponse (const IResponse &)=delete
 
 IResponse ()
 
- Public Member Functions inherited from LwIPClass
virtual ~LwIPClass ()
 

Public Attributes

const char * response
 
ConstHeader ct_header
 
bool done
 

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)
 

Detailed Description

Universal response class with internal buffer size by BUFFER_RESPONSE_SIZE.

Constructor & Destructor Documentation

◆ BufferResponse()

BufferResponse::BufferResponse ( )
126  : response(nullptr)
127  , ct_header("Content-Type", "application/binary")
128  , done(false) {}

Member Function Documentation

◆ printf()

int BufferResponse::printf ( const char *  format...)

write string data to internal buffer

131  {
132  int rv = 0;
133  va_list args;
134  va_start(args, format);
135  rv = vsnprintf(_buffer, BUFFER_RESPONSE_SIZE, format, args);
136  va_end(args);
137  return rv;
138  }

◆ buffer()

const uint8_t* BufferResponse::buffer ( ) const

return internal string buffer as array of bytes

141  {
142  return reinterpret_cast<const uint8_t *>(_buffer);
143  }
Here is the caller graph for this function:

◆ length()

int BufferResponse::length ( ) const

return length of internal string buffer

146  {
147  return strnlen(_buffer, BUFFER_RESPONSE_SIZE);
148  }
Here is the caller graph for this function:

◆ generator()

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

Response generator, iterative returns file data.

coroutine_fn returned BufferResponse data

Parameters
argpointer to BufferResponse object, which must be application function, and must be deleted by this function

Implements IResponse.

195  {
196  //const char* dummny = "This is dummy data. ";
197  Message_t msg = { nullptr, nullptr, nullptr, EOF };
198 
199  if (!done) {
200  msg = (Message_t) { response, &ct_header, buffer(), length() };
201  done = true;
202  }
203  return msg;
204 }
Here is the call graph for this function:

Member Data Documentation

◆ response

const char* BufferResponse::response

◆ ct_header

ConstHeader BufferResponse::ct_header

◆ done

bool BufferResponse::done
BufferResponse::done
bool done
Definition: connect.cpp:123
Message_t
Message which must be returned from coroutine generator.
Definition: lwsapi_app.hpp:211
BufferResponse::buffer
const uint8_t * buffer() const
return internal string buffer as array of bytes
Definition: connect.cpp:141
BufferResponse::length
int length() const
return length of internal string buffer
Definition: connect.cpp:146
BUFFER_RESPONSE_SIZE
#define BUFFER_RESPONSE_SIZE
Definition: connect.cpp:116
createSpeedLookupTable.args
args
Definition: createSpeedLookupTable.py:17
EOF
#define EOF
Definition: ff.h:286
BufferResponse::ct_header
ConstHeader ct_header
Definition: connect.cpp:122
BufferResponse::response
const char * response
Definition: connect.cpp:121