Prusa MINI Firmware overview
lwsapi.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6 
7 #include "lwip/err.h"
8 
9 //! Init (start) the LwIP WSAPI server.
10 err_t lwsapi_init(void);
11 
12 #ifdef __cplusplus
13 }
14 #endif
NumberHeader
NumberHeader is for number headers like Content-Length.
Definition: lwsapi_app.hpp:88
pbuf::len
u16_t len
Definition: pbuf.h:159
Message_t::response
const char * response
Definition: lwsapi_app.hpp:212
def.h
Context::state
State state
Definition: connection.hpp:30
Context::message
Message_t message
Definition: connection.hpp:32
lwsapi_init
err_t lwsapi_init(void)
Init (start) the LwIP WSAPI server.
Definition: lwsapi.cpp:413
lwsapi_accept
static err_t lwsapi_accept(void *arg, struct tcp_pcb *pcb, err_t err)
tcp_accept callback defined in LwIP
Definition: lwsapi.cpp:387
ERR_ABRT
Definition: err.h:90
LIGHT_WSAPI_RETRIES
#define LIGHT_WSAPI_RETRIES
Definition: lwsapi.cpp:11
u16_t
uint16_t u16_t
Definition: arch.h:121
http_bad_request
static const char * http_bad_request
Full Bad Request response.
Definition: lwsapi.cpp:15
IHeader
Headers list. Creator is responsible to clean the values.
Definition: lwsapi_app.hpp:70
pbuf::tot_len
u16_t tot_len
Definition: pbuf.h:156
IP_ANY_TYPE
#define IP_ANY_TYPE
Definition: ip_addr.h:400
TCP_SND_QUEUELEN
#define TCP_SND_QUEUELEN
Definition: opt.h:1212
number_header_factory
IHeader * number_header_factory(const char *key, const char *value, size_t value_length)
Response new NumberHeader.
Definition: lwsapi.cpp:445
data
uint8_t data[8]
Definition: masstorage.h:49
Context::fill_request_buffer
err_t fill_request_buffer(const struct pbuf *p)
Append pbuf to request_buffer.
Definition: connection.cpp:17
lwsapi_init
err_t lwsapi_init(void)
Init (start) the LwIP WSAPI server.
Definition: lwsapi.cpp:413
pbuf::next
struct pbuf * next
Definition: pbuf.h:144
pbuf_free
u8_t pbuf_free(struct pbuf *p)
Definition: pbuf.c:715
LIGHT_WSAPI_PORT
#define LIGHT_WSAPI_PORT
Definition: lwsapi.cpp:10
lwsapi_error
#define lwsapi_error
Definition: lwsapi_app.hpp:42
dbg.h
close_conn
static err_t close_conn(struct tcp_pcb *pcb, Context *ctx=nullptr)
Close connection and clean callbacks and other connection environment.
Definition: lwsapi.cpp:51
application
IResponse::unique_ptr_t application(Environment &env)
application_fn callback, which is called from LwIP WSAPI http server
Definition: connect.cpp:306
Context::prepare_response
err_t prepare_response()
Process message.response to internal buffer.
Definition: connection.cpp:152
Context
Internal connection structure which is used in LwIP tcp_ callbacks as arg.
Definition: connection.hpp:20
Context::prepare_header
err_t prepare_header()
Process message.headers to internal buffer.
Definition: connection.cpp:171
FIRST
Definition: connect.cpp:77
ERR_MEM
Definition: err.h:65
lwsapi_call
static void lwsapi_call(Context *ctx, const struct pbuf *input=nullptr)
Process message from IResponse::generator, and call generator for next work.
Definition: lwsapi.cpp:107
dynamics_header_factory
IHeader * dynamics_header_factory(const char *key, const char *value, size_t value_length)
Return new DynamicsHeader.
Definition: lwsapi.cpp:440
ERR_CLSD
Definition: err.h:94
connection.hpp
Context::retries
uint8_t retries
Definition: connection.hpp:29
err.h
Context::find_eoh
size_t find_eoh(const void *data=nullptr, size_t length=0)
Try to find End Of Header (\r \r ) in buffer.
Definition: connection.cpp:39
lwsapi_sent
static err_t lwsapi_sent(void *arg, struct tcp_pcb *pcb, u16_t len)
tcp_sent callback defined in LwIP
Definition: lwsapi.cpp:368
lwsapi_dbg
#define lwsapi_dbg
Definition: lwsapi_app.hpp:41
LIGHT_WSAPI_POLL_INTERVAL
#define LIGHT_WSAPI_POLL_INTERVAL
Definition: lwsapi.cpp:12
Message_t::length
int length
Definition: lwsapi_app.hpp:215
lwsapi.h
Context::pcb
struct tcp_pcb * pcb
Definition: connection.hpp:28
Context::response
IResponse::unique_ptr_t response
Definition: connection.hpp:37
Context::free_buffer
void free_buffer()
Definition: connection.hpp:94
uint8_t
const uint8_t[]
Definition: 404_html.c:3
IHeader::next
IHeader * next
Definition: lwsapi_app.hpp:73
lwsapi_poll
static err_t lwsapi_poll(void *arg, struct tcp_pcb *pcb)
The poll function is called every 2nd second.
Definition: lwsapi.cpp:83
Message_t
Message which must be returned from coroutine generator.
Definition: lwsapi_app.hpp:211
ERR_OK
Definition: err.h:63
err_t
s8_t err_t
Definition: err.h:57
ERR_RST
Definition: err.h:92
Message_t::payload
const uint8_t * payload
Definition: lwsapi_app.hpp:214
lwsapi_recv
static err_t lwsapi_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
Process http request and call application.
Definition: lwsapi.cpp:249
http_internal_server
static const char * http_internal_server
Full Internal Server Error response.
Definition: lwsapi.cpp:22
lwsapi_err
static void lwsapi_err(void *arg, err_t err)
tcp_err callback defined in LwIP
Definition: lwsapi.cpp:344
Context::m_position
size_t m_position
Definition: connection.hpp:34
Context::env
Environment env
Definition: connection.hpp:31
mem_malloc
void * mem_malloc(mem_size_t size)
Definition: mem.c:603
DynamicsHeader
DynamicsHeader store it's value to LwIP memory pool.
Definition: lwsapi_app.hpp:139
empty_message
static bool empty_message(const Message_t &msg)
Check when message is empty - all data was processed yet.
Definition: lwsapi.cpp:39
Environment::add_header
void add_header(IHeader *header)
Definition: lwsapi.cpp:28
timeouts.h
EOF
#define EOF
Definition: ff.h:286
mem_free
void mem_free(void *rmem)
Definition: mem.c:419
IPADDR_TYPE_ANY
Definition: ip_addr.h:60
ERR_VAL
Definition: err.h:75
pbuf
Definition: pbuf.h:142
lwsapi_write
static size_t lwsapi_write(Context *ctx, const uint8_t *data, size_t len)
Write data to TCP output buffer.
Definition: lwsapi.cpp:182
Context::parse_request
err_t parse_request(const void *data=nullptr, size_t length=0)
parste the request header (request line + request headers)
Definition: connection.cpp:110
memshift
#define memshift(ptr, size)
Definition: connection.hpp:10
pbuf::payload
void * payload
Definition: pbuf.h:147
Message_t::headers
const IHeader * headers
Definition: lwsapi_app.hpp:213
size
static png_bytep size_t size
Definition: pngwrite.c:2170
Context::buffer
char * buffer
Definition: connection.hpp:33