added esp docs from the rtos sdk

master
Ondřej Hruška 9 years ago
parent f3611453ad
commit b60506e11b
  1. 834
      esp_iot_sdk_v1.5.2/include/espconn.h
  2. 1610
      esp_iot_sdk_v1.5.2/include/user_interface.h
  3. 2
      esp_meas.pro.user
  4. 2
      include/ets_sys_extra.h
  5. 3
      libesphttpd/include/espmissingprotos.h

@ -7,7 +7,45 @@
typedef sint8 err_t; typedef sint8 err_t;
typedef void *espconn_handle; typedef void *espconn_handle;
/**
* @brief Connect callback.
*
* Callback which will be called if successful listening (ESP8266 as TCP server)
* or connection (ESP8266 as TCP client) callback, register by espconn_regist_connectcb.
*
* @attention The pointer "void *arg" may be different in different callbacks, please don't
* use this pointer directly to distinguish one from another in multiple connections,
* use remote_ip and remote_port in espconn instead.
*
* @param void *arg : pointer corresponding structure espconn.
*
* @return null
*/
typedef void (* espconn_connect_callback)(void *arg); typedef void (* espconn_connect_callback)(void *arg);
/**
* @brief Reconnect callback.
*
* Enter this callback when error occurred, TCP connection broke. This callback is
* registered by espconn_regist_reconcb.
*
* @attention The pointer "void *arg" may be different in different callbacks, please don't
* use this pointer directly to distinguish one from another in multiple connections,
* use remote_ip and remote_port in espconn instead.
*
* @param void *arg : pointer corresponding structure espconn.
* @param sint8 err : error code
* - ESCONN_TIMEOUT - Timeout
* - ESPCONN_ABRT - TCP connection aborted
* - ESPCONN_RST - TCP connection abort
* - ESPCONN_CLSD - TCP connection closed
* - ESPCONN_CONN - TCP connection
* - ESPCONN_HANDSHAKE - TCP SSL handshake fail
* - ESPCONN_PROTO_MSG - SSL application invalid
*
* @return null
*/
typedef void (* espconn_reconnect_callback)(void *arg, sint8 err); typedef void (* espconn_reconnect_callback)(void *arg, sint8 err);
/* Definitions for error constants. */ /* Definitions for error constants. */
@ -33,46 +71,44 @@ typedef void (* espconn_reconnect_callback)(void *arg, sint8 err);
/** Protocol family and type of the espconn */ /** Protocol family and type of the espconn */
enum espconn_type { enum espconn_type {
ESPCONN_INVALID = 0, ESPCONN_INVALID = 0, /**< invalid type */
/* ESPCONN_TCP Group */ ESPCONN_TCP = 0x10, /**< TCP */
ESPCONN_TCP = 0x10, ESPCONN_UDP = 0x20, /**< UDP */
/* ESPCONN_UDP Group */
ESPCONN_UDP = 0x20,
}; };
/** Current state of the espconn. Non-TCP espconn are always in state ESPCONN_NONE! */ /** Current state of the espconn. */
enum espconn_state { enum espconn_state {
ESPCONN_NONE, ESPCONN_NONE, /**< idle state, no connection */
ESPCONN_WAIT, ESPCONN_WAIT, /**< ESP8266 is as TCP client, and waiting for connection */
ESPCONN_LISTEN, ESPCONN_LISTEN, /**< ESP8266 is as TCP server, and waiting for connection */
ESPCONN_CONNECT, ESPCONN_CONNECT, /**< connected */
ESPCONN_WRITE, ESPCONN_WRITE, /**< sending data */
ESPCONN_READ, ESPCONN_READ, /**< receiving data */
ESPCONN_CLOSE ESPCONN_CLOSE /**< connection closed */
}; };
typedef struct _esp_tcp { typedef struct _esp_tcp {
int remote_port; int remote_port; /**< remote port of TCP connection */
int local_port; int local_port; /**< ESP8266's local port of TCP connection */
uint8 local_ip[4]; uint8 local_ip[4]; /**< local IP of ESP8266 */
uint8 remote_ip[4]; uint8 remote_ip[4]; /**< remote IP of TCP connection */
espconn_connect_callback connect_callback; espconn_connect_callback connect_callback; /**< connected callback */
espconn_reconnect_callback reconnect_callback; espconn_reconnect_callback reconnect_callback; /**< as error handler, the TCP connection broke unexpectedly */
espconn_connect_callback disconnect_callback; espconn_connect_callback disconnect_callback; /**< disconnected callback */
espconn_connect_callback write_finish_fn; espconn_connect_callback write_finish_fn; /**< data send by espconn_send has wrote into buffer waiting for sending, or has sent successfully */
} esp_tcp; } esp_tcp;
typedef struct _esp_udp { typedef struct _esp_udp {
int remote_port; int remote_port; /**< remote port of UDP transmission */
int local_port; int local_port; /**< ESP8266's local port for UDP transmission */
uint8 local_ip[4]; uint8 local_ip[4]; /**< local IP of ESP8266 */
uint8 remote_ip[4]; uint8 remote_ip[4]; /**< remote IP of UDP transmission */
} esp_udp; } esp_udp;
typedef struct _remot_info { typedef struct _remot_info {
enum espconn_state state; enum espconn_state state; /**< state of espconn */
int remote_port; int remote_port; /**< remote port */
uint8 remote_ip[4]; uint8 remote_ip[4]; /**< remote IP address */
} remot_info; } remot_info;
/** A callback prototype to inform about events for a espconn */ /** A callback prototype to inform about events for a espconn */
@ -81,34 +117,31 @@ typedef void (* espconn_sent_callback)(void *arg);
/** A espconn descriptor */ /** A espconn descriptor */
struct espconn { struct espconn {
/** type of the espconn (TCP, UDP) */ enum espconn_type type; /**< type of the espconn (TCP or UDP) */
enum espconn_type type; enum espconn_state state; /**< current state of the espconn */
/** current state of the espconn */
enum espconn_state state;
union { union {
esp_tcp *tcp; esp_tcp *tcp;
esp_udp *udp; esp_udp *udp;
} proto; } proto;
/** A callback function that is informed about events for this espconn */ espconn_recv_callback recv_callback; /**< data received callback */
espconn_recv_callback recv_callback; espconn_sent_callback sent_callback; /**< data sent callback */
espconn_sent_callback sent_callback; uint8 link_cnt; /**< link count */
uint8 link_cnt; void *reserve; /**< reserved for user data */
void *reverse;
}; };
enum espconn_option { enum espconn_option {
ESPCONN_START = 0x00, ESPCONN_START = 0x00, /**< no option, start enum. */
ESPCONN_REUSEADDR = 0x01, ESPCONN_REUSEADDR = 0x01, /**< free memory after TCP disconnection happen, need not wait 2 minutes. */
ESPCONN_NODELAY = 0x02, ESPCONN_NODELAY = 0x02, /**< disable nagle algorithm during TCP data transmission, quicken the data transmission. */
ESPCONN_COPY = 0x04, ESPCONN_COPY = 0x04, /**< enable espconn_regist_write_finish, enter write_finish_callback means that the data espconn_send sending was written into 2920 bytes write-buffer waiting for sending or already sent. */
ESPCONN_KEEPALIVE = 0x08, ESPCONN_KEEPALIVE = 0x08, /**< enable TCP keep alive. */
ESPCONN_END ESPCONN_END /**< no option, end enum. */
}; };
enum espconn_level { enum espconn_level {
ESPCONN_KEEPIDLE, ESPCONN_KEEPIDLE, /**< TCP keep-alive interval, unit : second. */
ESPCONN_KEEPINTVL, ESPCONN_KEEPINTVL, /**< packet interval during TCP keep-alive, unit : second. */
ESPCONN_KEEPCNT ESPCONN_KEEPCNT /**< maximum packet retry count of TCP keep-alive. */
}; };
enum { enum {
@ -136,106 +169,168 @@ struct mdns_info {
unsigned long ipAddr; unsigned long ipAddr;
char *txt_data[10]; char *txt_data[10];
}; };
/******************************************************************************
* FunctionName : espconn_connect
* Description : The function given as the connect
* Parameters : espconn -- the espconn used to listen the connection
* Returns : none
*******************************************************************************/
/**
* @brief Connect to a TCP server (ESP8266 acting as TCP client).
*
* @attention If espconn_connect fail, returns non-0 value, there is no connection, so it
* won't enter any espconn callback.
*
* @param struct espconn *espconn : the network connection structure, the espconn to
* listen to the connection
*
* @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_RTE - Routing Problem
* - ESPCONN_MEM - Out of memory
* - ESPCONN_ISCONN - Already connected
* - ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection
* according to structure espconn
*/
sint8 espconn_connect(struct espconn *espconn); sint8 espconn_connect(struct espconn *espconn);
/****************************************************************************** /**
* FunctionName : espconn_disconnect * @brief Disconnect a TCP connection.
* Description : disconnect with host *
* Parameters : espconn -- the espconn used to disconnect the connection * @attention Don't call this API in any espconn callback. If needed, please use system
* Returns : none * task to trigger espconn_disconnect.
*******************************************************************************/ *
* @param struct espconn *espconn : the network connection structure
*
* @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection
* according to structure espconn
*/
sint8 espconn_disconnect(struct espconn *espconn); sint8 espconn_disconnect(struct espconn *espconn);
/****************************************************************************** /**
* FunctionName : espconn_delete * @brief Delete a transmission.
* Description : disconnect with host *
* Parameters : espconn -- the espconn used to disconnect the connection * @attention Corresponding creation API :
* Returns : none * - TCP: espconn_accept,
*******************************************************************************/ * - UDP: espconn_create
*
* @param struct espconn *espconn : the network connection structure
*
* @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_ARG - illegal argument, can't find the corresponding network according
* to structure espconn
*/
sint8 espconn_delete(struct espconn *espconn); sint8 espconn_delete(struct espconn *espconn);
/****************************************************************************** /**
* FunctionName : espconn_accept * @brief Creates a TCP server (i.e. accepts connections).
* Description : The function given as the listen *
* Parameters : espconn -- the espconn used to listen the connection * @param struct espconn *espconn : the network connection structure
* Returns : none *
*******************************************************************************/ * @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_MEM - Out of memory
* - ESPCONN_ISCONN - Already connected
* - ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection
* according to structure espconn
*/
sint8 espconn_accept(struct espconn *espconn); sint8 espconn_accept(struct espconn *espconn);
/****************************************************************************** /**
* FunctionName : espconn_create * @brief Create UDP transmission.
* Description : sent data for client or server *
* Parameters : espconn -- espconn to the data transmission * @attention Parameter remote_ip and remote_port need to be set, do not set to be 0.
* Returns : result *
*******************************************************************************/ * @param struct espconn *espconn : the UDP control block structure
*
* @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_MEM - Out of memory
* - ESPCONN_ISCONN - Already connected
* - ESPCONN_ARG - illegal argument, can't find the corresponding UDP transmission
* according to structure espconn
*/
sint8 espconn_create(struct espconn *espconn); sint8 espconn_create(struct espconn *espconn);
/******************************************************************************
* FunctionName : espconn_tcp_get_max_con
* Description : get the number of simulatenously active TCP connections
* Parameters : none
* Returns : none
*******************************************************************************/
/**
* @brief Get maximum number of how many TCP connections are allowed.
*
* @param null
*
* @return Maximum number of how many TCP connections are allowed.
*/
uint8 espconn_tcp_get_max_con(void); uint8 espconn_tcp_get_max_con(void);
/****************************************************************************** /**
* FunctionName : espconn_tcp_set_max_con * @brief Set the maximum number of how many TCP connection is allowed.
* Description : set the number of simulatenously active TCP connections *
* Parameters : num -- total number * @param uint8 num : Maximum number of how many TCP connection is allowed.
* Returns : none *
*******************************************************************************/ * @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection
* according to structure espconn
*/
sint8 espconn_tcp_set_max_con(uint8 num); sint8 espconn_tcp_set_max_con(uint8 num);
/****************************************************************************** /**
* FunctionName : espconn_tcp_get_max_con_allow * @brief Get the maximum number of TCP clients which are allowed to connect to ESP8266 TCP server.
* Description : get the count of simulatenously active connections on the server *
* Parameters : espconn -- espconn to get the count * @param struct espconn *espconn : the TCP server structure
* Returns : result *
*******************************************************************************/ * @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according
* to structure espconn
*/
sint8 espconn_tcp_get_max_con_allow(struct espconn *espconn); sint8 espconn_tcp_get_max_con_allow(struct espconn *espconn);
/****************************************************************************** /**
* FunctionName : espconn_tcp_set_max_con_allow * @brief Set the maximum number of TCP clients allowed to connect to ESP8266 TCP server.
* Description : set the count of simulatenously active connections on the server *
* Parameters : espconn -- espconn to set the count * @param struct espconn *espconn : the TCP server structure
* num -- support the connection number * @param uint8 num : Maximum number of TCP clients which are allowed
* Returns : result *
*******************************************************************************/ * @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according
* to structure espconn
*/
sint8 espconn_tcp_set_max_con_allow(struct espconn *espconn, uint8 num); sint8 espconn_tcp_set_max_con_allow(struct espconn *espconn, uint8 num);
/****************************************************************************** /**
* FunctionName : espconn_regist_time * @brief Register timeout interval of ESP8266 TCP server.
* Description : used to specify the time that should be called when don't recv data *
* Parameters : espconn -- the espconn used to the connection * @attention 1. If timeout is set to 0, timeout will be disable and ESP8266 TCP server will
* interval -- the timer when don't recv data * not disconnect TCP clients has stopped communication. This usage of timeout=0,
* Returns : none * is deprecated.
*******************************************************************************/ * @attention 2. This timeout interval is not very precise, only as reference.
*
* @param struct espconn *espconn : the TCP connection structure
* @param uint32 interval : timeout interval, unit: second, maximum: 7200 seconds
* @param uint8 type_flag : 0, set for all connections; 1, set for a specific connection
* - If the type_flag set to be 0, please call this API after espconn_accept, before listened
* a TCP connection.
* - If the type_flag set to be 1, the first parameter *espconn is the specific connection.
*
* @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according
* to structure espconn
*/
sint8 espconn_regist_time(struct espconn *espconn, uint32 interval, uint8 type_flag); sint8 espconn_regist_time(struct espconn *espconn, uint32 interval, uint8 type_flag);
/****************************************************************************** /**
* FunctionName : espconn_get_connection_info * @brief Get the information about a TCP connection or UDP transmission.
* Description : used to specify the function that should be called when disconnect *
* Parameters : espconn -- espconn to set the err callback * @param struct espconn *espconn : the network connection structure
* discon_cb -- err callback function to call when err * @param remot_info **pcon_info : connect to client info
* Returns : none * @param uint8 typeflags : 0, regular server; 1, ssl server
*******************************************************************************/ *
* @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_ARG - illegal argument, can't find the corresponding transmission according to
* structure espconn
*/
sint8 espconn_get_connection_info(struct espconn *pespconn, remot_info **pcon_info, uint8 typeflags); sint8 espconn_get_connection_info(struct espconn *pespconn, remot_info **pcon_info, uint8 typeflags);
/****************************************************************************** /******************************************************************************
@ -248,191 +343,269 @@ sint8 espconn_get_connection_info(struct espconn *pespconn, remot_info **pcon_in
sint8 espconn_get_packet_info(struct espconn *espconn, struct espconn_packet* infoarg); sint8 espconn_get_packet_info(struct espconn *espconn, struct espconn_packet* infoarg);
/****************************************************************************** /**
* FunctionName : espconn_regist_sentcb * @brief Register data sent callback which will be called back when data are successfully sent.
* Description : Used to specify the function that should be called when data *
* has been successfully delivered to the remote host. * @param struct espconn *espconn : the network connection structure
* Parameters : struct espconn *espconn -- espconn to set the sent callback * @param espconn_sent_callback sent_cb : registered callback function which will be called if
* espconn_sent_callback sent_cb -- sent callback function to * the data is successfully sent
* call for this espconn when data is successfully sent *
* Returns : none * @return 0 : succeed
*******************************************************************************/ * @return Non-0 : error code
* - ESPCONN_ARG - illegal argument, can't find the corresponding transmission according
* to structure espconn
*/
sint8 espconn_regist_sentcb(struct espconn *espconn, espconn_sent_callback sent_cb); sint8 espconn_regist_sentcb(struct espconn *espconn, espconn_sent_callback sent_cb);
/****************************************************************************** /**
* FunctionName : espconn_regist_sentcb * @brief Register a callback which will be called when all sending TCP data is completely
* Description : Used to specify the function that should be called when data * write into write-buffer or sent.
* has been successfully delivered to the remote host. *
* Parameters : espconn -- espconn to set the sent callback * Need to call espconn_set_opt to enable write-buffer first.
* sent_cb -- sent callback function to call for this espconn *
* when data is successfully sent * @attention 1. write-buffer is used to keep TCP data that waiting to be sent, queue number
* Returns : none * of the write-buffer is 8 which means that it can keep 8 packets at most.
*******************************************************************************/ * The size of write-buffer is 2920 bytes.
* @attention 2. Users can enable it by using espconn_set_opt.
* @attention 3. Users can call espconn_send to send the next packet in write_finish_callback
* instead of using espconn_sent_callback.
*
* @param struct espconn *espconn : the network connection structure
* @param espconn_connect_callback write_finish_fn : registered callback function which will
* be called if the data is completely write
* into write buffer or sent.
*
* @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according
* to structure espconn
*/
sint8 espconn_regist_write_finish(struct espconn *espconn, espconn_connect_callback write_finish_fn); sint8 espconn_regist_write_finish(struct espconn *espconn, espconn_connect_callback write_finish_fn);
/****************************************************************************** /**
* FunctionName : espconn_send * @brief Send data through network.
* Description : sent data for client or server *
* Parameters : espconn -- espconn to set for client or server * @attention 1. Please call espconn_send after espconn_sent_callback of the pre-packet.
* psent -- data to send * @attention 2. If it is a UDP transmission, it is suggested to set espconn->proto.udp->remote_ip
* length -- length of data to send * and remote_port before every calling of espconn_send.
* Returns : none *
*******************************************************************************/ * @param struct espconn *espconn : the network connection structure
* @param uint8 *psent : pointer of data
* @param uint16 length : data length
*
* @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_MEM - Out of memory
* - ESPCONN_ARG - illegal argument, can't find the corresponding network transmission
* according to structure espconn
* - ESPCONN_MAXNUM - buffer of sending data is full
* - ESPCONN_IF - send UDP data fail
*/
sint8 espconn_send(struct espconn *espconn, uint8 *psent, uint16 length); sint8 espconn_send(struct espconn *espconn, uint8 *psent, uint16 length);
/****************************************************************************** /**
* FunctionName : espconn_sent * @brief Send data through network.
* Description : sent data for client or server *
* Parameters : espconn -- espconn to set for client or server * This API is deprecated, please use espconn_send instead.
* psent -- data to send *
* length -- length of data to send * @attention 1. Please call espconn_sent after espconn_sent_callback of the pre-packet.
* Returns : none * @attention 2. If it is a UDP transmission, it is suggested to set espconn->proto.udp->remote_ip
*******************************************************************************/ * and remote_port before every calling of espconn_sent.
*
* @param struct espconn *espconn : the network connection structure
* @param uint8 *psent : pointer of data
* @param uint16 length : data length
*
* @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_MEM - Out of memory
* - ESPCONN_ARG - illegal argument, can't find the corresponding network transmission
* according to structure espconn
* - ESPCONN_MAXNUM - buffer of sending data is full
* - ESPCONN_IF - send UDP data fail
*/
sint8 espconn_sent(struct espconn *espconn, uint8 *psent, uint16 length); sint8 espconn_sent(struct espconn *espconn, uint8 *psent, uint16 length);
/****************************************************************************** /**
* FunctionName : espconn_sendto * @brief Send UDP data.
* Description : send data for UDP *
* Parameters : espconn -- espconn to set for UDP * @param struct espconn *espconn : the UDP structure
* psent -- data to send * @param uint8 *psent : pointer of data
* length -- length of data to send * @param uint16 length : data length
* Returns : error *
*******************************************************************************/ * @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_MEM - Out of memory
* - ESPCONN_MAXNUM - buffer of sending data is full
* - ESPCONN_IF - send UDP data fail
*/
sint16 espconn_sendto(struct espconn *espconn, uint8 *psent, uint16 length); sint16 espconn_sendto(struct espconn *espconn, uint8 *psent, uint16 length);
/****************************************************************************** /**
* FunctionName : espconn_regist_connectcb * @brief Register connection function which will be called back under successful TCP connection.
* Description : used to specify the function that should be called when *
* connects to host. * @param struct espconn *espconn : the TCP connection structure
* Parameters : espconn -- espconn to set the connect callback * @param espconn_connect_callback connect_cb : registered callback function
* connect_cb -- connected callback function to call when connected *
* Returns : none * @return 0 : succeed
*******************************************************************************/ * @return Non-0 : error code
* - ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according
* to structure espconn
*/
sint8 espconn_regist_connectcb(struct espconn *espconn, espconn_connect_callback connect_cb); sint8 espconn_regist_connectcb(struct espconn *espconn, espconn_connect_callback connect_cb);
/****************************************************************************** /**
* FunctionName : espconn_regist_recvcb * @brief register data receive function which will be called back when data are received.
* Description : used to specify the function that should be called when recv *
* data from host. * @param struct espconn *espconn : the network transmission structure
* Parameters : espconn -- espconn to set the recv callback * @param espconn_recv_callback recv_cb : registered callback function
* recv_cb -- recv callback function to call when recv data *
* Returns : none * @return 0 : succeed
*******************************************************************************/ * @return Non-0 : error code
* - ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according
* to structure espconn
*/
sint8 espconn_regist_recvcb(struct espconn *espconn, espconn_recv_callback recv_cb); sint8 espconn_regist_recvcb(struct espconn *espconn, espconn_recv_callback recv_cb);
/****************************************************************************** /**
* FunctionName : espconn_regist_reconcb * @brief Register reconnect callback.
* Description : used to specify the function that should be called when connection *
* because of err disconnect. * @attention espconn_reconnect_callback is more like a network-broken error handler; it handles
* Parameters : espconn -- espconn to set the err callback * errors that occurs in any phase of the connection.
* recon_cb -- err callback function to call when err * For instance, if espconn_send fails, espconn_reconnect_callback will be called
* Returns : none * because the network is broken.
*******************************************************************************/ *
* @param struct espconn *espconn : the TCP connection structure
* @param espconn_reconnect_callback recon_cb : registered callback function
*
* @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according
* to structure espconn
*/
sint8 espconn_regist_reconcb(struct espconn *espconn, espconn_reconnect_callback recon_cb); sint8 espconn_regist_reconcb(struct espconn *espconn, espconn_reconnect_callback recon_cb);
/****************************************************************************** /**
* FunctionName : espconn_regist_disconcb * @brief Register disconnection function which will be called back under successful TCP
* Description : used to specify the function that should be called when disconnect * disconnection.
* Parameters : espconn -- espconn to set the err callback *
* discon_cb -- err callback function to call when err * @param struct espconn *espconn : the TCP connection structure
* Returns : none * @param espconn_connect_callback discon_cb : registered callback function
*******************************************************************************/ *
* @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according
* to structure espconn
*/
sint8 espconn_regist_disconcb(struct espconn *espconn, espconn_connect_callback discon_cb); sint8 espconn_regist_disconcb(struct espconn *espconn, espconn_connect_callback discon_cb);
/****************************************************************************** /**
* FunctionName : espconn_port * @brief Get an available port for network.
* Description : access port value for client so that we don't end up bouncing *
* all connections at the same time . * @param null
* Parameters : none *
* Returns : access port value * @return Port number.
*******************************************************************************/ */
uint32 espconn_port(void); uint32 espconn_port(void);
/****************************************************************************** /**
* FunctionName : espconn_set_opt * @brief Set option of TCP connection.
* Description : access port value for client so that we don't end up bouncing *
* all connections at the same time . * @attention In general, we need not call this API. If call espconn_set_opt, please call
* Parameters : none * it in espconn_connect_callback.
* Returns : access port value *
*******************************************************************************/ * @param struct espconn *espconn : the TCP connection structure
* @param uint8 opt : option of TCP connection, refer to enum espconn_option
* - bit 0: 1: free memory after TCP disconnection happen need not wait 2 minutes;
* - bit 1: 1: disable nagle algorithm during TCP data transmission, quiken the data transmission.
* - bit 2: 1: enable espconn_regist_write_finish, enter write finish callback means
* the data espconn_send sending was written into 2920 bytes write-buffer
* waiting for sending or already sent.
* - bit 3: 1: enable TCP keep alive
*
* @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according
* to structure espconn
*/
sint8 espconn_set_opt(struct espconn *espconn, uint8 opt); sint8 espconn_set_opt(struct espconn *espconn, uint8 opt);
/****************************************************************************** /**
* FunctionName : espconn_clear_opt * @brief Clear option of TCP connection.
* Description : clear the option for connections so that we don't end up bouncing *
* all connections at the same time . * @param struct espconn *espconn : the TCP connection structure
* Parameters : espconn -- the espconn used to set the connection * @param uint8 opt : enum espconn_option
* opt -- the option for clear *
* Returns : the result * @return 0 : succeed
*******************************************************************************/ * @return Non-0 : error code
* - ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according
* to structure espconn
*/
sint8 espconn_clear_opt(struct espconn *espconn, uint8 opt); sint8 espconn_clear_opt(struct espconn *espconn, uint8 opt);
/****************************************************************************** /**
* FunctionName : espconn_set_keepalive * @brief Set configuration of TCP keep alive.
* Description : access level value for connection so that we set the value for *
* keep alive * @attention In general, we need not call this API. If needed, please call it in
* Parameters : espconn -- the espconn used to set the connection * espconn_connect_callback and call espconn_set_opt to enable keep alive first.
* level -- the connection's level *
* value -- the value of time(s) * @param struct espconn *espconn : the TCP connection structure
* Returns : access port value * @param uint8 level : To do TCP keep-alive detection every ESPCONN_KEEPIDLE. If there
*******************************************************************************/ * is no response, retry ESPCONN_KEEPCNT times every ESPCONN_KEEPINTVL.
* If still no response, considers it as TCP connection broke, goes
* into espconn_reconnect_callback. Notice, keep alive interval is not
* precise, only for reference, it depends on priority.
* @param void* optarg : value of parameter
*
* @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according
* to structure espconn
*/
sint8 espconn_set_keepalive(struct espconn *espconn, uint8 level, void *optarg); sint8 espconn_set_keepalive(struct espconn *espconn, uint8 level, void *optarg);
/****************************************************************************** /**
* FunctionName : espconn_get_keepalive * @brief Get configuration of TCP keep alive.
* Description : access level value for connection so that we get the value for *
* keep alive * @param struct espconn *espconn : the TCP connection structure
* Parameters : espconn -- the espconn used to get the connection * @param uint8 level : enum espconn_level
* level -- the connection's level * @param void* optarg : value of parameter
* Returns : access keep alive value *
*******************************************************************************/ * @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection according
* to structure espconn
*/
sint8 espconn_get_keepalive(struct espconn *espconn, uint8 level, void *optarg); sint8 espconn_get_keepalive(struct espconn *espconn, uint8 level, void *optarg);
/****************************************************************************** /**
* TypedefName : dns_found_callback * @brief Callback which is invoked when a hostname is found.
* Description : Callback which is invoked when a hostname is found. *
* Parameters : name -- pointer to the name that was looked up. * @param const char *name : hostname
* ipaddr -- pointer to an ip_addr_t containing the IP address of * @param ip_addr_t *ipaddr : IP address of the hostname, or to be NULL if the name could
* the hostname, or NULL if the name could not be found (or on any * not be found (or on any other error).
* other error). * @param void *callback_arg : callback argument.
* callback_arg -- a user-specified callback argument passed to *
* dns_gethostbyname * @return null
*******************************************************************************/ */
typedef void (*dns_found_callback)(const char *name, ip_addr_t *ipaddr, void *callback_arg); typedef void (*dns_found_callback)(const char *name, ip_addr_t *ipaddr, void *callback_arg);
/****************************************************************************** /**
* FunctionName : espconn_gethostbyname * @brief DNS function.
* Description : Resolve a hostname (string) into an IP address. *
* Parameters : pespconn -- espconn to resolve a hostname * Parse a hostname (string) to an IP address.
* hostname -- the hostname that is to be queried *
* addr -- pointer to a ip_addr_t where to store the address if * @param struct espconn *pespconn : espconn to parse a hostname.
* it is already cached in the dns_table (only valid if ESPCONN_OK * @param const char *hostname : the hostname.
* is returned!) * @param ip_addr_t *addr : IP address.
* found -- a callback function to be called on success, failure * @param dns_found_callback found : callback of DNS
* or timeout (only if ERR_INPROGRESS is returned!) *
* Returns : err_t return code * @return err_t :
* - ESPCONN_OK if hostname is a valid IP address string or the host * - ESPCONN_OK - succeed
* name is already in the local names table. * - ESPCONN_INPROGRESS - error code : already connected
* - ESPCONN_INPROGRESS enqueue a request to be sent to the DNS server * - ESPCONN_ARG - error code : illegal argument, can't find network transmission
* for resolution if no errors are present. * according to structure espconn
* - ESPCONN_ARG: dns client not initialized or invalid hostname */
*******************************************************************************/
err_t espconn_gethostbyname(struct espconn *pespconn, const char *hostname, ip_addr_t *addr, dns_found_callback found); err_t espconn_gethostbyname(struct espconn *pespconn, const char *hostname, ip_addr_t *addr, dns_found_callback found);
/****************************************************************************** /******************************************************************************
@ -590,38 +763,61 @@ sint8 espconn_secure_accept(struct espconn *espconn);
sint8 espconn_secure_delete(struct espconn *espconn); sint8 espconn_secure_delete(struct espconn *espconn);
/****************************************************************************** /**
* FunctionName : espconn_igmp_join * @brief Join a multicast group.
* Description : join a multicast group *
* Parameters : host_ip -- the ip address of udp server * @attention This API can only be called after the ESP8266 station connects to a router.
* multicast_ip -- multicast ip given by user *
* Returns : none * @param ip_addr_t *host_ip : IP of UDP host
*******************************************************************************/ * @param ip_addr_t *multicast_ip : IP of multicast group
*
* @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_MEM - Out of memory
*/
sint8 espconn_igmp_join(ip_addr_t *host_ip, ip_addr_t *multicast_ip); sint8 espconn_igmp_join(ip_addr_t *host_ip, ip_addr_t *multicast_ip);
/****************************************************************************** /**
* FunctionName : espconn_igmp_leave * @brief Leave a multicast group.
* Description : leave a multicast group *
* Parameters : host_ip -- the ip address of udp server * @attention This API can only be called after the ESP8266 station connects to a router.
* multicast_ip -- multicast ip given by user *
* Returns : none * @param ip_addr_t *host_ip : IP of UDP host
*******************************************************************************/ * @param ip_addr_t *multicast_ip : IP of multicast group
*
* @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_MEM - Out of memory
*/
sint8 espconn_igmp_leave(ip_addr_t *host_ip, ip_addr_t *multicast_ip); sint8 espconn_igmp_leave(ip_addr_t *host_ip, ip_addr_t *multicast_ip);
/****************************************************************************** /**
* FunctionName : espconn_recv_hold * @brief Puts in a request to block the TCP receive function.
* Description : hold tcp receive *
* Parameters : espconn -- espconn to hold * @attention The function does not act immediately; we recommend calling it while
* Returns : none * reserving 5*1460 bytes of memory. This API can be called more than once.
*******************************************************************************/ *
* @param struct espconn *espconn : corresponding TCP connection structure
*
* @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection
* according to structure espconn.
*/
sint8 espconn_recv_hold(struct espconn *pespconn); sint8 espconn_recv_hold(struct espconn *pespconn);
/****************************************************************************** /**
* FunctionName : espconn_recv_unhold * @brief Unblock TCP receiving data (i.e. undo espconn_recv_hold).
* Description : unhold tcp receive *
* Parameters : espconn -- espconn to unhold * @attention This API takes effect immediately.
* Returns : none *
*******************************************************************************/ * @param struct espconn *espconn : corresponding TCP connection structure
*
* @return 0 : succeed
* @return Non-0 : error code
* - ESPCONN_ARG - illegal argument, can't find the corresponding TCP connection
* according to structure espconn.
*/
sint8 espconn_recv_unhold(struct espconn *pespconn); sint8 espconn_recv_unhold(struct espconn *pespconn);
/****************************************************************************** /******************************************************************************
@ -631,16 +827,16 @@ sint8 espconn_recv_unhold(struct espconn *pespconn);
* hostname -- the hostname of device * hostname -- the hostname of device
* Returns : none * Returns : none
*******************************************************************************/ *******************************************************************************/
void espconn_mdns_init(struct mdns_info *info); void espconn_mdns_init(struct mdns_info *info);
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_mdns_close * FunctionName : espconn_mdns_close
* Description : close a device with mdns * Description : close a device with mdns
* Parameters : a * Parameters : a
* Returns : none * Returns : none
*******************************************************************************/ *******************************************************************************/
void espconn_mdns_close(void); void espconn_mdns_close(void);
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_mdns_server_register * FunctionName : espconn_mdns_server_register
* Description : register a device with mdns * Description : register a device with mdns
@ -662,9 +858,9 @@ void espconn_mdns_server_unregister(void);
* Description : get server name of device with mdns * Description : get server name of device with mdns
* Parameters : a * Parameters : a
* Returns : none * Returns : none
*******************************************************************************/ ******************************************************************************/
char* espconn_mdns_get_servername(void); char* espconn_mdns_get_servername(void);
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_mdns_set_servername * FunctionName : espconn_mdns_set_servername
* Description : set server name of device with mdns * Description : set server name of device with mdns
@ -704,14 +900,18 @@ void espconn_mdns_disable(void);
* Returns : none * Returns : none
*******************************************************************************/ *******************************************************************************/
void espconn_mdns_enable(void); void espconn_mdns_enable(void);
/******************************************************************************
* FunctionName : espconn_dns_setserver /**
* Description : Initialize one of the DNS servers. * @brief Set default DNS server. Two DNS server is allowed to be set.
* Parameters : numdns -- the index of the DNS server to set must *
* be < DNS_MAX_SERVERS = 2 * @attention Only if ESP8266 DHCP client is disabled (wifi_station_dhcpc_stop),
* dnsserver -- IP address of the DNS server to set * this API can be used.
* Returns : none *
*******************************************************************************/ * @param char numdns : DNS server ID, 0 or 1
* @param ip_addr_t *dnsserver : DNS server IP
*
* @return null
*/
void espconn_dns_setserver(char numdns, ip_addr_t *dnsserver); void espconn_dns_setserver(char numdns, ip_addr_t *dnsserver);
#endif #endif

File diff suppressed because it is too large Load Diff

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.6.1, 2016-04-05T21:58:52. --> <!-- Written by QtCreator 3.6.1, 2016-04-21T21:17:01. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

@ -13,5 +13,5 @@ extern void system_soft_wdt_feed();
extern int ets_str2macaddr(void *, void *); extern int ets_str2macaddr(void *, void *);
extern void ets_update_cpu_frequency(int freqmhz); extern void ets_update_cpu_frequency(int freqmhz);
extern int os_printf_plus(const char *format, ...) __attribute__ ((format (printf, 1, 2))); extern int os_printf_plus(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
extern uint8 wifi_get_opmode(void); //extern uint8 wifi_get_opmode(void);
extern void ets_bzero(void *s, size_t n); extern void ets_bzero(void *s, size_t n);

@ -10,6 +10,7 @@ int strcasecmp(const char *a, const char *b);
#include <eagle_soc.h> #include <eagle_soc.h>
#include <ets_sys.h> #include <ets_sys.h>
#include <os_type.h> #include <os_type.h>
//#include <user_interface.h>
//Missing function prototypes in include folders. Gcc will warn on these if we don't define 'em anywhere. //Missing function prototypes in include folders. Gcc will warn on these if we don't define 'em anywhere.
//MOST OF THESE ARE GUESSED! but they seem to swork and shut up the compiler. //MOST OF THESE ARE GUESSED! but they seem to swork and shut up the compiler.
typedef struct espconn espconn; typedef struct espconn espconn;
@ -40,7 +41,7 @@ int os_printf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
int os_snprintf(char *str, size_t size, const char *format, ...) __attribute__ ((format (printf, 3, 4))); int os_snprintf(char *str, size_t size, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
int os_printf_plus(const char *format, ...) __attribute__ ((format (printf, 1, 2))); int os_printf_plus(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
void uart_div_modify(int no, unsigned int freq); void uart_div_modify(int no, unsigned int freq);
uint8 wifi_get_opmode(void); //uint8 wifi_get_opmode(void);
uint32 system_get_time(); uint32 system_get_time();
int rand(void); int rand(void);
void ets_bzero(void *s, size_t n); void ets_bzero(void *s, size_t n);

Loading…
Cancel
Save