126 lines
3.1 KiB
C
126 lines
3.1 KiB
C
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
|
|
#ifndef UNUSED
|
|
#define UNUSED(x) (void)(x)
|
|
#endif
|
|
|
|
#define LWIP_UNUSED_ARG(x) UNUSED(x)
|
|
|
|
typedef int8_t err_t;
|
|
/** Definitions for error constants. */
|
|
typedef enum {
|
|
/** No error, everything OK. */
|
|
ERR_OK = 0,
|
|
/** Out of memory error. */
|
|
ERR_MEM = -1,
|
|
/** Buffer error. */
|
|
ERR_BUF = -2,
|
|
/** Timeout. */
|
|
ERR_TIMEOUT = -3,
|
|
/** Routing problem. */
|
|
ERR_RTE = -4,
|
|
/** Operation in progress */
|
|
ERR_INPROGRESS = -5,
|
|
/** Illegal value. */
|
|
ERR_VAL = -6,
|
|
/** Operation would block. */
|
|
ERR_WOULDBLOCK = -7,
|
|
/** Address in use. */
|
|
ERR_USE = -8,
|
|
/** Already connecting. */
|
|
ERR_ALREADY = -9,
|
|
/** Conn already established.*/
|
|
ERR_ISCONN = -10,
|
|
/** Not connected. */
|
|
ERR_CONN = -11,
|
|
/** Low-level netif error */
|
|
ERR_IF = -12,
|
|
|
|
/** Connection aborted. */
|
|
ERR_ABRT = -13,
|
|
/** Connection reset. */
|
|
ERR_RST = -14,
|
|
/** Connection closed. */
|
|
ERR_CLSD = -15,
|
|
/** Illegal argument. */
|
|
ERR_ARG = -16
|
|
} err_enum_t;
|
|
|
|
struct pbuf {
|
|
struct pbuf *next;
|
|
void *payload;
|
|
uint16_t tot_len;
|
|
uint16_t len;
|
|
uint8_t type_internal;
|
|
uint8_t flags;
|
|
//LWIP_PBUF_REF_T ref;
|
|
|
|
uint8_t if_idx;
|
|
};
|
|
|
|
struct tcp_pcb {
|
|
uint8_t state;
|
|
};
|
|
typedef void sFONT;
|
|
|
|
#define ERR_OK 0
|
|
#define LCD_COLOR_BLACK 0
|
|
#define LCD_COLOR_WHITE 1
|
|
#define LCD_TRANSPARENT 2
|
|
|
|
#define LCD_FONT16 0
|
|
#define LCD_FONT24 (void*)1
|
|
|
|
#define TCP_WRITE_FLAG_COPY 0x01
|
|
#define TCP_WRITE_FLAG_MORE 0x02
|
|
|
|
#define TCP_PRIO_MIN 1
|
|
#define TCP_PRIO_NORMAL 64
|
|
#define TCP_PRIO_MAX 127
|
|
#define IP_ADDR_ANY 0
|
|
|
|
typedef err_t (*tcp_recv_fn)(void *arg, struct tcp_pcb *tpcb,
|
|
struct pbuf *p, err_t err);
|
|
|
|
typedef err_t (*tcp_accept_fn)(void *arg, struct tcp_pcb *newpcb, err_t err);
|
|
|
|
uint32_t logger_get_timestamp(void);
|
|
|
|
void lcd_display_text(const char* text, uint16_t x_pos, uint16_t y_pos, uint32_t color, uint32_t bg_color, sFONT *font);
|
|
void lcd_draw_img_from_fs(char* filename, uint32_t x_pos, uint32_t y_pos);
|
|
void lcd_draw_gif_from_fs(char* filename, uint32_t x_pos, uint32_t y_pos);
|
|
void lcd_draw_bmp_img(uint8_t* bmp_buff, uint32_t x_pos, uint32_t y_pos);
|
|
void lcd_draw_gif(uint8_t* gif_buff, size_t len, uint32_t x_pos, uint32_t y_pos);
|
|
|
|
void lcd_clear_images(void);
|
|
void lcd_clear_text(void);
|
|
|
|
struct tcp_pcb* tcp_new(void);
|
|
err_t tcp_bind(void *pcb, void *ipaddr, uint16_t port);
|
|
struct tcp_pcb* tcp_listen(void *pcb);
|
|
void tcp_accept(void *pcb, tcp_accept_fn arg);
|
|
void tcp_arg(void *pcb, void *arg);
|
|
void tcp_sent(void *pcb, void *arg);
|
|
void tcp_recv(void *pcb, tcp_recv_fn arg);
|
|
void tcp_setprio(void *pcb, uint8_t prio);
|
|
void tcp_err(void *pcb, void* err);
|
|
void tcp_poll(void *pcb, void* poll, uint8_t interval);
|
|
void tcp_close(void *pcb);
|
|
|
|
void tcp_write(void *pcb, const char *data, size_t len, uint8_t apiflags);
|
|
void tcp_output(void *pcb);
|
|
void tcp_recved(void *pcb, uint16_t len);
|
|
void pbuf_free(struct pbuf* p);
|
|
|
|
size_t tcp_sndbuf(void *pcb);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif |