ESP8266 ILI9341 display support code with printf sources, wire-frame viewer and custom fonts
1.0
ESP8266ILI9341DisplayProject
|
Small web server for esp8266. More...
Go to the source code of this file.
Data Structures | |
struct | hinfo_t |
struct | mem_t |
struct | header_t |
struct | mime_t |
struct | rwbuf_t |
Macros | |
#define | MAX_CONNECTIONS 1 |
#define | IO_MAX 512 |
Typedefs | |
typedef struct espconn | espconn_t |
Enumerations | |
enum | { TOKEN_GET, TOKEN_PUT, TOKEN_POST, TOKEN_HEAD, TOKEN_HOST, TOKEN_USER_AGENT, TOKEN_HTTPS, TOKEN_DNT, TOKEN_ACCEPT, TOKEN_ACCEPT_LANGUAGE, TOKEN_ACCEPT_ENCODING, TOKEN_CONNECTION, TOKEN_REFERER, TOKEN_CONTENT_LENGTH, TOKEN_CONTENT_TYPE, TOKEN_CACHE_CONTROL } |
enum | { STATUS_OK =200, STATUS_CREATED =201, STATUS_ACCEPTED =202, STATUS_NO_CONTENT =204, STATUS_MV_PERM =301, STATUS_MV_TEMP =302, STATUS_NOT_MODIF =304, STATUS_BAD_REQ =400, STATUS_UNAUTH =401, STATUS_FORBIDDEN =403, STATUS_NOT_FOUND =404, STATUS_INT_SERR =500, STATUS_NOT_IMPL =501, STATUS_BAD_GATEWAY =502, STATUS_SERV_UNAVAIL =503 } |
enum | { PTYPE_TEXT, PTYPE_HTML, PTYPE_PDF, PTYPE_CSS, PTYPE_CGI, PTYPE_JS, PTYPE_XML, PTYPE_ICO, PTYPE_GIF, PTYPE_JPEG, PTYPE_MPEG, PTYPE_FLASH, PTYPE_ERR } |
Functions | |
MEMSPACE void | web_sep (void) |
printer seperator More... | |
MEMSPACE int | wait_send (rwbuf_t *p) |
Wait for buffer to send for this connection If write_buffer sending flag is set then wait for it to clear. More... | |
MEMSPACE int | write_buffer (rwbuf_t *p) |
Socket write buffer for this connection We wait for previous send to complete - then send any new data We do not wait for new data to finish sending - you use flush for that. More... | |
MEMSPACE int | write_flush (rwbuf_t *p) |
Write all outstanding data and wait for it to send. More... | |
MEMSPACE int | write_byte (rwbuf_t *p, int c) |
Write a byte (buffered) using the rwbuf_t socket buffers for this connection If the buffers are full the socket is written using write_flush. More... | |
MEMSPACE void | led_on (int led) |
MEMSPACE void | led_off (int led) |
Turn off virtual LED. More... | |
MEMSPACE void | rwbuf_rinit (rwbuf_t *p) |
Initialize socket read status and read index. More... | |
MEMSPACE void | rwbuf_winit (rwbuf_t *p) |
Initialize socket send status and write index. More... | |
MEMSPACE void | display_ipv4 (char *msg, uint8_t *ip, int port) |
Display IPV4 address. More... | |
MEMSPACE void | rwbuf_delete (rwbuf_t *p) |
Delete socket read/write buffers. More... | |
MEMSPACE rwbuf_t * | rwbuf_create (void) |
Create socket read/write buffer for a connection. More... | |
MEMSPACE rwbuf_t * | find_connection (espconn_t *conn, int *index, char *msg) |
Find a read/write socket buffer for an espconn connection. More... | |
MEMSPACE rwbuf_t * | create_connection (espconn_t *conn) |
Allocate read/write socket buffers and add it to the working pool. More... | |
MEMSPACE int | delete_connection (rwbuf_t *p) |
Delete our main connection structure and connection buffers. More... | |
MEMSPACE void | write_len (rwbuf_t *p, char *str, int len) |
Write data using buffered write_byte function. More... | |
MEMSPACE void | write_str (rwbuf_t *p, char *str) |
Write string using buffered write_byte function. More... | |
MEMSPACE int | vsock_printf (rwbuf_t *p, const char *fmt, va_list va) |
vsock_printf function More... | |
MEMSPACE int | sock_printf (rwbuf_t *p, const char *fmt,...) |
sock_printf function More... | |
MEMSPACE int | html_msg (rwbuf_t *p, int status, char type, char *fmt,...) |
Send an HTML status message to socket. More... | |
MEMSPACE char * | meminit (mem_t *p, char *ptr, int size) |
in memory memory gets function More... | |
MEMSPACE char * | memgets (mem_t *p) |
Memory gets function We ASSUME we can replace any with a \0. More... | |
MEMSPACE char * | mime_type (int type) |
return strung pointer for mime type index More... | |
MEMSPACE int | file_type (char *name) |
Determin mimetype using file name extension. More... | |
MEMSPACE char * | html_status (int status) |
Convert html status into string using http_status table. More... | |
MEMSPACE void | init_hinfo (hinfo_t *hi) |
MEMSPACE int | match_headers (char *str, char **p) |
Match GET/POST message headers. More... | |
MEMSPACE char * | process_args (hinfo_t *hi, char *ptr) |
Process GET argments or POST message name/value data. HTML encoding is done in place often reducting the size of the result. Convert name=value pairs into null terminated strings. Names and values are each terminated with an EOS by replaceing '?', '&', '=' characters seen while scaning. More... | |
MEMSPACE char * | first_arg (hinfo_t *hi) |
Find first POST/GET argument. More... | |
MEMSPACE char * | next_arg (hinfo_t *hi) |
Find next POST/GET argument We have to skip a name and a value. More... | |
MEMSPACE char * | arg_name (hinfo_t *hi) |
Return the argument name for current argument. More... | |
MEMSPACE char * | arg_value (hinfo_t *hi) |
Return the argument value for current argument. More... | |
MEMSPACE char * | http_value (hinfo_t *hi, char *str) |
Lookup and argument name and return its value. More... | |
MEMSPACE int | is_header (char *str, char **p) |
Does the string look like a header token with a ':' ? More... | |
MEMSPACE char * | nextbreak (char *ptr) |
Find next space or ? character. More... | |
MEMSPACE void | u5toa (char *ptr, uint16_t num) |
Print a decimal number into a string without an EOS. More... | |
MEMSPACE void | html_head (rwbuf_t *p, int status, char type, int len) |
Write HTTP Contenet-Type/Content-Length header. More... | |
MEMSPACE int | parse_http_request (rwbuf_t *p, hinfo_t *hi) |
Get arguments for a GET or POST request. More... | |
MEMSPACE int | is_cgitoken_char (int c) |
test to see if a character is a valid member of the CGI token character set CGI tokens have the following syntax @ They start with "@_" and end with "_@" "@_" must be first two characters of string May have upper and lower case letters, numbers and '-' More... | |
MEMSPACE int | find_cgitoken_start (char *str) |
Find start of CGI token in a string CGI tokens have the following syntax @ They start with "@_" and end with "_@" "@_" must be first two characters of string May have upper and lower case letters, numbers and '-' param[in] *str: string to search. More... | |
MEMSPACE int | is_cgitoken (char *str) |
Does the string have a CGI TOKEN at the beginning ? CGI tokens have the following syntax @ They start with "@_" and end with "_@" "@_" must be first two characters of string May have upper and lower case letters, numbers and '-'. More... | |
MEMSPACE int | rewrite_cgi_token (rwbuf_t *p, char *src) |
Replace CGI token with CGI result CGI tokens have the following syntax @ They start with "@_" and end with "_@" "@_" must be first two characters of string May have upper and lower case letters, numbers and '-'. More... | |
MEMSPACE void | web_task (void) |
Process ALL incoming HTTP requests. More... | |
MEMSPACE void | web_init_connections (void) |
MEMSPACE void | web_init (int port) |
Setup WEB server and accept connections. More... | |
Small web server for esp8266.
This is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file web.h.
#define MAX_CONNECTIONS 1 |
Definition at line 31 of file web.h.
Referenced by create_connection(), delete_connection(), find_connection(), setup(), and tcp_accept().
anonymous enum |
anonymous enum |
anonymous enum |
Return the argument name for current argument.
[in] | *hi | hinfo_t structure with arguments |
Definition at line 1298 of file web.c.
Referenced by http_value(), and parse_http_request().
Return the argument value for current argument.
[in] | *hi | hinfo_t structure with arguments |
Definition at line 1346 of file web.c.
Referenced by http_value(), and parse_http_request().
Allocate read/write socket buffers and add it to the working pool.
[in] | conn | espconn pointer for this connection |
Definition at line 669 of file web.c.
Referenced by web_data_connect_callback().
Delete our main connection structure and connection buffers.
[in] | p | rwbuf_t pointer |
Definition at line 715 of file web.c.
Referenced by web_data_disconnect_callback().
Display IPV4 address.
[in] | msg | user supplied message |
[in] | ip | IP address as uint8_t [4] |
[in] | port | Port number |
Definition at line 470 of file web.c.
Referenced by delete_connection(), find_connection(), web_data_connect_callback(), web_data_disconnect_callback(), web_data_error_callback(), web_data_receive_callback(), and web_data_sent_callback().
MEMSPACE int file_type | ( | char * | name | ) |
MEMSPACE int find_cgitoken_start | ( | char * | str | ) |
Find start of CGI token in a string CGI tokens have the following syntax @ They start with "@_" and end with "_@" "@_" must be first two characters of string May have upper and lower case letters, numbers and '-' param[in] *str: string to search.
Find a read/write socket buffer for an espconn connection.
[in] | conn | espconn pointer for this connection |
[in] | *index | return index into pool of rwbuf_t connections |
[in] | *msg | user debug message |
Definition at line 590 of file web.c.
Referenced by web_data_disconnect_callback(), web_data_error_callback(), web_data_receive_callback(), and web_data_sent_callback().
Find first POST/GET argument.
[in] | *hi | hinfo_t structure with arguments |
Definition at line 1235 of file web.c.
Referenced by http_value(), and parse_http_request().
MEMSPACE char* html_status | ( | int | status | ) |
Convert html status into string using http_status table.
[in] | status | html status number |
Definition at line 1030 of file web.c.
Referenced by html_head(), and html_msg().
MEMSPACE int is_cgitoken | ( | char * | str | ) |
Does the string have a CGI TOKEN at the beginning ? CGI tokens have the following syntax @ They start with "@_" and end with "_@" "@_" must be first two characters of string May have upper and lower case letters, numbers and '-'.
/**
MEMSPACE int is_cgitoken_char | ( | int | c | ) |
test to see if a character is a valid member of the CGI token character set CGI tokens have the following syntax @ They start with "@_" and end with "_@" "@_" must be first two characters of string May have upper and lower case letters, numbers and '-'
[in] | c | character to test |
MEMSPACE int is_header | ( | char * | str, |
char ** | p | ||
) |
Does the string look like a header token with a ':' ?
[in] | *str | string to test |
[in] | **p | string pointer to set on match |
Definition at line 1451 of file web.c.
Referenced by parse_http_request().
MEMSPACE void led_off | ( | int | led | ) |
MEMSPACE int match_headers | ( | char * | str, |
char ** | p | ||
) |
Match GET/POST message headers.
[in] | *str | string to patch |
[in] | **p | points past matched string on sucess |
Definition at line 1077 of file web.c.
Referenced by parse_http_request().
Memory gets function We ASSUME we can replace any
with a \0.
[in] | p | structure with size and offset used by mem_gets() |
Definition at line 952 of file web.c.
Referenced by parse_http_request().
in memory memory gets function
[in] | p | structure with size and offset used by mem_gets() |
[in] | ptr | start of memory area |
[in] | size | size of memory area |
Definition at line 933 of file web.c.
Referenced by parse_http_request().
MEMSPACE char* mime_type | ( | int | type | ) |
return strung pointer for mime type index
[in] | type | index into mim_type table |
Definition at line 983 of file web.c.
Referenced by html_head(), and html_msg().
Find next POST/GET argument We have to skip a name and a value.
[in] | *hi | hinfo_t structure with arguments |
Definition at line 1247 of file web.c.
Referenced by http_value(), and parse_http_request().
MEMSPACE char* nextbreak | ( | char * | ptr | ) |
Find next space or ? character.
[in] | *ptr | string to search |
Definition at line 1476 of file web.c.
Referenced by parse_http_request().
Process GET argments or POST message name/value data. HTML encoding is done in place often reducting the size of the result. Convert name=value pairs into null terminated strings. Names and values are each terminated with an EOS by replaceing '?', '&', '=' characters seen while scaning.
[in] | *hi | hinfo_t structure to fill |
[in] | *ptr | GET arguments or PUT message body. |
Definition at line 1116 of file web.c.
Referenced by parse_http_request().
Replace CGI token with CGI result CGI tokens have the following syntax @ They start with "@_" and end with "_@" "@_" must be first two characters of string May have upper and lower case letters, numbers and '-'.
[in] | *p | socket stream |
[in] | *str | string with token, example @ |
Create socket read/write buffer for a connection.
Definition at line 526 of file web.c.
Referenced by create_connection().
Delete socket read/write buffers.
[in] | p | rwbuf_t pointer to buffer to delete |
Definition at line 487 of file web.c.
Referenced by delete_connection(), and rwbuf_create().
Initialize socket read status and read index.
[in] | p | rwbuf_t pointer |
Definition at line 439 of file web.c.
Referenced by rwbuf_create(), rwbuf_delete(), and web_data_receive_callback().
Initialize socket send status and write index.
[in] | p | rwbuf_t pointer |
Definition at line 453 of file web.c.
Referenced by rwbuf_create(), rwbuf_delete(), and web_data_sent_callback().
sock_printf function
[in] | p | socket buffer structure |
[in] | fmt | printf format string |
[in] | ... | list of arguments |
Definition at line 830 of file web.c.
Referenced by html_head().
Print a decimal number into a string without an EOS.
[in] | *ptr | buffer to write number to |
[in] | num | number to convet |
Definition at line 1497 of file web.c.
Referenced by html_msg().
vsock_printf function
[in] | p | socket buffer structure |
[in] | fmt | printf format string |
[in] | va | va_list of arguments |
Definition at line 808 of file web.c.
Referenced by sock_printf().
Wait for buffer to send for this connection If write_buffer sending flag is set then wait for it to clear.
[in] | *p | rwbuf_t pointer for this socket buffer |
Definition at line 195 of file web.c.
Referenced by write_buffer(), and write_flush().
MEMSPACE void web_init | ( | int | port | ) |
MEMSPACE void web_sep | ( | void | ) |
MEMSPACE void web_task | ( | void | ) |
Process ALL incoming HTTP requests.
Definition at line 2441 of file web.c.
Referenced by loop_wrapper().
Socket write buffer for this connection We wait for previous send to complete - then send any new data We do not wait for new data to finish sending - you use flush for that.
[in] | *p | rwbuf_t pointer for this socket buffer |
Definition at line 266 of file web.c.
Referenced by write_flush().
Write a byte (buffered) using the rwbuf_t socket buffers for this connection If the buffers are full the socket is written using write_flush.
[in] | *p | rwbuf_t pointer for this socket buffer |
[in] | 1 | on success 0 on fail |
Definition at line 339 of file web.c.
Referenced by _write_byte_fn(), write_len(), and write_str().
Write all outstanding data and wait for it to send.
[in] | *p | rwbuf_t pointer for this socket buffer |
Definition at line 323 of file web.c.
Referenced by write_byte().
Write data using buffered write_byte function.
[in] | *p | rwbuf_t pointer for this socket buffer |
[in] | *str | data buffer to write |
[in] | len | number of bytes to write |
Definition at line 758 of file web.c.
Referenced by html_msg().