2017-04-13 11:14:01 +00:00
|
|
|
/* tcp_perf Example
|
|
|
|
|
|
|
|
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, this
|
|
|
|
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
|
|
CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2017-03-20 05:43:04 +00:00
|
|
|
#ifndef __TCP_PERF_H__
|
|
|
|
#define __TCP_PERF_H__
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-04-13 11:14:01 +00:00
|
|
|
|
2017-03-20 05:43:04 +00:00
|
|
|
/*test options*/
|
2017-04-13 11:14:01 +00:00
|
|
|
#define EXAMPLE_ESP_WIFI_MODE_AP CONFIG_TCP_PERF_WIFI_MODE_AP //TRUE:AP FALSE:STA
|
|
|
|
#define EXAMPLE_ESP_TCP_MODE_SERVER CONFIG_TCP_PERF_SERVER //TRUE:server FALSE:client
|
|
|
|
#define EXAMPLE_ESP_TCP_PERF_TX CONFIG_TCP_PERF_TX //TRUE:send FALSE:receive
|
|
|
|
#define EXAMPLE_ESP_TCP_DELAY_INFO CONFIG_TCP_PERF_DELAY_DEBUG //TRUE:show delay time info
|
|
|
|
|
|
|
|
/*AP info and tcp_server info*/
|
|
|
|
#define EXAMPLE_DEFAULT_SSID CONFIG_TCP_PERF_WIFI_SSID
|
|
|
|
#define EXAMPLE_DEFAULT_PWD CONFIG_TCP_PERF_WIFI_PASSWORD
|
|
|
|
#define EXAMPLE_DEFAULT_PORT CONFIG_TCP_PERF_SERVER_PORT
|
|
|
|
#define EXAMPLE_DEFAULT_PKTSIZE CONFIG_TCP_PERF_PKT_SIZE
|
|
|
|
#define EXAMPLE_MAX_STA_CONN 1 //how many sta can be connected(AP mode)
|
|
|
|
|
|
|
|
#ifdef CONFIG_TCP_PERF_SERVER_IP
|
|
|
|
#define EXAMPLE_DEFAULT_SERVER_IP CONFIG_TCP_PERF_SERVER_IP
|
|
|
|
#else
|
|
|
|
#define EXAMPLE_DEFAULT_SERVER_IP "192.168.4.1"
|
|
|
|
#endif /*CONFIG_TCP_PERF_SERVER_IP*/
|
2017-03-20 05:43:04 +00:00
|
|
|
|
|
|
|
|
2017-04-13 11:14:01 +00:00
|
|
|
|
|
|
|
#define EXAMPLE_PACK_BYTE_IS 97 //'a'
|
2017-03-20 05:43:04 +00:00
|
|
|
#define TAG "tcp_perf:"
|
|
|
|
|
2017-04-13 11:14:01 +00:00
|
|
|
/* FreeRTOS event group to signal when we are connected to wifi*/
|
|
|
|
extern EventGroupHandle_t tcp_event_group;
|
|
|
|
#define WIFI_CONNECTED_BIT BIT0
|
2017-03-20 05:43:04 +00:00
|
|
|
|
2017-07-21 03:40:30 +00:00
|
|
|
extern int g_total_data;
|
|
|
|
extern bool g_rxtx_need_restart;
|
2017-03-21 12:06:32 +00:00
|
|
|
|
2017-04-13 11:14:01 +00:00
|
|
|
#if EXAMPLE_ESP_TCP_PERF_TX && EXAMPLE_ESP_TCP_DELAY_INFO
|
2017-07-21 03:40:30 +00:00
|
|
|
extern int g_total_pack;
|
|
|
|
extern int g_send_success;
|
|
|
|
extern int g_send_fail;
|
|
|
|
extern int g_delay_classify[5];
|
2017-04-13 11:14:01 +00:00
|
|
|
#endif/*EXAMPLE_ESP_TCP_PERF_TX && EXAMPLE_ESP_TCP_DELAY_INFO*/
|
2017-03-21 12:06:32 +00:00
|
|
|
|
2017-03-20 05:43:04 +00:00
|
|
|
|
|
|
|
//using esp as station
|
|
|
|
void wifi_init_sta();
|
|
|
|
//using esp as softap
|
|
|
|
void wifi_init_softap();
|
|
|
|
|
2017-04-10 12:39:04 +00:00
|
|
|
//create a tcp server socket. return ESP_OK:success ESP_FAIL:error
|
|
|
|
esp_err_t create_tcp_server();
|
|
|
|
//create a tcp client socket. return ESP_OK:success ESP_FAIL:error
|
|
|
|
esp_err_t create_tcp_client();
|
2017-03-20 05:43:04 +00:00
|
|
|
|
|
|
|
//send data task
|
|
|
|
void send_data(void *pvParameters);
|
|
|
|
//receive data task
|
|
|
|
void recv_data(void *pvParameters);
|
|
|
|
|
|
|
|
//close all socket
|
|
|
|
void close_socket();
|
|
|
|
|
2017-04-13 11:14:01 +00:00
|
|
|
//get socket error code. return: error code
|
|
|
|
int get_socket_error_code(int socket);
|
|
|
|
|
2017-03-23 08:36:32 +00:00
|
|
|
//show socket error code. return: error code
|
2017-07-21 03:40:30 +00:00
|
|
|
int show_socket_error_reason(const char* str, int socket);
|
2017-03-20 05:43:04 +00:00
|
|
|
|
2017-03-23 08:36:32 +00:00
|
|
|
//check working socket
|
2017-04-13 11:14:01 +00:00
|
|
|
int check_working_socket();
|
2017-03-20 05:43:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-03-21 12:06:32 +00:00
|
|
|
|
|
|
|
#endif /*#ifndef __TCP_PERF_H__*/
|
2017-03-20 05:43:04 +00:00
|
|
|
|