openthread: add iperf example for ot-network test
This commit is contained in:
@@ -1,16 +1,8 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "esp_check.h"
|
||||
#include "esp_err.h"
|
||||
@@ -30,8 +22,9 @@ static void udp_socket_server_task(void *pvParameters)
|
||||
int err = 0;
|
||||
int len;
|
||||
int listen_sock;
|
||||
|
||||
int port = CONFIG_OPENTHREAD_CLI_UDP_SERVER_PORT;
|
||||
struct timeval timeout;
|
||||
struct timeval timeout = { 0 };
|
||||
struct sockaddr_storage source_addr; // Large enough for both IPv4 or IPv6
|
||||
struct sockaddr_in6 listen_addr;
|
||||
|
||||
@@ -39,7 +32,7 @@ static void udp_socket_server_task(void *pvParameters)
|
||||
listen_addr.sin6_family = AF_INET6;
|
||||
listen_addr.sin6_port = htons(port);
|
||||
|
||||
listen_sock = socket(AF_INET6, SOCK_DGRAM, IPPROTO_IPV6);
|
||||
listen_sock = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
|
||||
ESP_GOTO_ON_FALSE((listen_sock >= 0), ESP_OK, exit, TAG, "Unable to create socket: errno %d", errno);
|
||||
ESP_LOGI(TAG, "Socket created");
|
||||
|
||||
@@ -98,7 +91,7 @@ static void udp_socket_client_task(void *pvParameters)
|
||||
dest_addr.sin6_family = AF_INET6;
|
||||
dest_addr.sin6_port = htons(port);
|
||||
|
||||
client_sock = socket(AF_INET6, SOCK_DGRAM, IPPROTO_IPV6);
|
||||
client_sock = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
|
||||
ESP_GOTO_ON_FALSE((client_sock >= 0), ESP_OK, exit, TAG, "Unable to create socket: errno %d", errno);
|
||||
ESP_LOGI(TAG, "Socket created, sending to %s:%d", host_ip, port);
|
||||
|
||||
@@ -135,7 +128,7 @@ void esp_ot_process_udp_client(void *aContext, uint8_t aArgsLength, char *aArgs[
|
||||
{
|
||||
(void)(aContext);
|
||||
(void)(aArgsLength);
|
||||
if (aArgs[0] == NULL) {
|
||||
if (aArgsLength == 0) {
|
||||
ESP_LOGE(TAG, "Invalid arguments.");
|
||||
} else {
|
||||
xTaskCreate(udp_socket_client_task, "ot_udp_socket_client", 4096, aArgs[0], 4, NULL);
|
||||
|
||||
Reference in New Issue
Block a user