2017-04-13 11:14:01 +00:00
|
|
|
/* udp_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-21 12:06:32 +00:00
|
|
|
#ifndef __UDP_PERF_H__
|
|
|
|
#define __UDP_PERF_H__
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-04-13 11:14:01 +00:00
|
|
|
|
2017-03-21 12:06:32 +00:00
|
|
|
/*test options*/
|
2017-04-13 11:14:01 +00:00
|
|
|
#define EXAMPLE_ESP_WIFI_MODE_AP CONFIG_UDP_PERF_WIFI_MODE_AP //TRUE:AP FALSE:STA
|
|
|
|
#define EXAMPLE_ESP_UDP_MODE_SERVER CONFIG_UDP_PERF_SERVER //TRUE:server FALSE:client
|
|
|
|
#define EXAMPLE_ESP_UDP_PERF_TX CONFIG_UDP_PERF_TX //TRUE:send FALSE:receive
|
|
|
|
#define EXAMPLE_PACK_BYTE_IS 97 //'a'
|
|
|
|
/*AP info and tcp_server info*/
|
|
|
|
#define EXAMPLE_DEFAULT_SSID CONFIG_UDP_PERF_WIFI_SSID
|
|
|
|
#define EXAMPLE_DEFAULT_PWD CONFIG_UDP_PERF_WIFI_PASSWORD
|
|
|
|
#define EXAMPLE_DEFAULT_PORT CONFIG_UDP_PERF_SERVER_PORT
|
|
|
|
#define EXAMPLE_DEFAULT_PKTSIZE CONFIG_UDP_PERF_PKT_SIZE
|
|
|
|
#define EXAMPLE_MAX_STA_CONN 1 //how many sta can be connected(AP mode)
|
|
|
|
|
|
|
|
#ifdef CONFIG_UDP_PERF_SERVER_IP
|
|
|
|
#define EXAMPLE_DEFAULT_SERVER_IP CONFIG_UDP_PERF_SERVER_IP
|
|
|
|
#else
|
|
|
|
#define EXAMPLE_DEFAULT_SERVER_IP "192.168.4.1"
|
|
|
|
#endif /*CONFIG_UDP_PERF_SERVER_IP*/
|
|
|
|
|
2017-03-21 12:06:32 +00:00
|
|
|
|
|
|
|
#define TAG "udp_perf:"
|
|
|
|
|
2017-04-13 11:14:01 +00:00
|
|
|
/* FreeRTOS event group to signal when we are connected to WiFi and ready to start UDP test*/
|
|
|
|
extern EventGroupHandle_t udp_event_group;
|
|
|
|
#define WIFI_CONNECTED_BIT BIT0
|
|
|
|
#define UDP_CONNCETED_SUCCESS BIT1
|
2017-03-21 12:06:32 +00:00
|
|
|
|
2017-04-10 12:39:04 +00:00
|
|
|
extern int total_data;
|
2017-03-21 12:06:32 +00:00
|
|
|
extern int success_pack;
|
|
|
|
|
|
|
|
|
|
|
|
//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 udp server socket. return ESP_OK:success ESP_FAIL:error
|
|
|
|
esp_err_t create_udp_server();
|
|
|
|
//create a udp client socket. return ESP_OK:success ESP_FAIL:error
|
|
|
|
esp_err_t create_udp_client();
|
2017-03-21 12:06:32 +00:00
|
|
|
|
|
|
|
//send or recv data task
|
|
|
|
void send_recv_data(void *pvParameters);
|
|
|
|
|
2017-04-13 11:14:01 +00:00
|
|
|
//get socket error code. return: error code
|
|
|
|
int get_socket_error_code(int socket);
|
|
|
|
|
2017-04-10 12:39:04 +00:00
|
|
|
//show socket error code. return: error code
|
2017-04-13 11:14:01 +00:00
|
|
|
int show_socket_error_reason(int socket);
|
|
|
|
|
|
|
|
//check connected socket. return: error code
|
|
|
|
int check_connected_socket();
|
2017-04-10 12:39:04 +00:00
|
|
|
|
2017-03-21 12:06:32 +00:00
|
|
|
//close all socket
|
|
|
|
void close_socket();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#endif /*#ifndef __UDP_PERF_H__*/
|
|
|
|
|