61 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			61 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
#ifndef HTTPD_SOCKET_CLIENT_H
 | 
						|
#define HTTPD_SOCKET_CLIENT_H
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
extern "C" {
 | 
						|
#endif
 | 
						|
 | 
						|
#define IP4_ADDR_LEN            4
 | 
						|
 | 
						|
#define SOCKET_CONN_RPT_STATUS  (0x80000000)
 | 
						|
 | 
						|
typedef enum {
 | 
						|
    CLIENT_CONN_IDLE = 0,
 | 
						|
    CLIENT_CONN_CONNING,
 | 
						|
    CLIENT_CONN_CONNECTED,
 | 
						|
} client_conn_state;
 | 
						|
 | 
						|
typedef struct _iot_eth_config_t {
 | 
						|
    uint8_t local_ip[IP4_ADDR_LEN];
 | 
						|
    uint8_t mask[IP4_ADDR_LEN];
 | 
						|
    uint8_t gateway[IP4_ADDR_LEN];
 | 
						|
    uint32_t server_ip;
 | 
						|
    uint32_t port;
 | 
						|
} iot_eth_config_t;
 | 
						|
 | 
						|
typedef int8_t (*http_client_recv_fn)(int8_t* buf, uint16_t len);
 | 
						|
 | 
						|
/* client init */
 | 
						|
int8_t httpd_client_init(iot_eth_config_t *cfg);
 | 
						|
 | 
						|
/**
 | 
						|
 * set server addr
 | 
						|
 *
 | 
						|
 * @param server_ip: the ip of the server
 | 
						|
 * @param server_port: the port of the server 8081
 | 
						|
 * @return the return value of gs_client_connect
 | 
						|
 */
 | 
						|
int8_t httpd_client_set_server_addr(uint32_t server_ip, const uint16_t server_port);
 | 
						|
 | 
						|
/* client data to server */
 | 
						|
int32_t httpd_client_send(const void* ptr, uint16_t length);
 | 
						|
 | 
						|
/* client reveive data from server */
 | 
						|
int8_t httpd_client_register_recv(http_client_recv_fn recv);
 | 
						|
 | 
						|
/* close connect with server */
 | 
						|
int32_t httpd_client_close();
 | 
						|
 | 
						|
/* get client state connected or not */
 | 
						|
uint32_t httpd_client_get_state(void);
 | 
						|
 | 
						|
/* disable client connected report state */
 | 
						|
void httpd_client_disable_connect_state_rpt(void);
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
}
 | 
						|
#endif
 | 
						|
 | 
						|
#endif /* HTTPD_SOCKET_CLIENT_H */
 | 
						|
 |