examples: add socket stdin utils to common connect component
This commit is contained in:
parent
995ef85e85
commit
a5a750ba48
9 changed files with 27 additions and 21 deletions
|
@ -1,4 +1,4 @@
|
||||||
idf_component_register(SRCS "connect.c" "stdin_out.c"
|
idf_component_register(SRCS "connect.c" "stdin_out.c" "addr_from_stdin.c"
|
||||||
INCLUDE_DIRS "include"
|
INCLUDE_DIRS "include"
|
||||||
PRIV_REQUIRES esp_netif
|
PRIV_REQUIRES esp_netif
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,3 +1,21 @@
|
||||||
|
/* Common utilities for socket address input interface:
|
||||||
|
The API get_addr_from_stdin() is mainly used by socket client examples which read IP address from stdin (if configured).
|
||||||
|
This option is typically used in the CI, but could be enabled in the project configuration.
|
||||||
|
In that case this component is used to receive a string that is evaluated and processed to output
|
||||||
|
socket structures to open a connectio
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "lwip/sys.h"
|
#include "lwip/sys.h"
|
||||||
#include <lwip/netdb.h>
|
#include <lwip/netdb.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
@ -19,4 +37,8 @@
|
||||||
esp_err_t get_addr_from_stdin(int port, int sock_type,
|
esp_err_t get_addr_from_stdin(int port, int sock_type,
|
||||||
int *ip_protocol,
|
int *ip_protocol,
|
||||||
int *addr_family,
|
int *addr_family,
|
||||||
struct sockaddr_in6 *dest_addr);
|
struct sockaddr_in6 *dest_addr);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -1,3 +0,0 @@
|
||||||
idf_component_register(SRCS "addr_from_stdin.c"
|
|
||||||
INCLUDE_DIRS "include"
|
|
||||||
PRIV_REQUIRES protocol_examples_common)
|
|
|
@ -1,6 +0,0 @@
|
||||||
# Socket address input
|
|
||||||
|
|
||||||
This directory contains a common component for socket client examples which read IP address from stdin (if configured).
|
|
||||||
This option is typically used in the CI, but could be enabled in the project configuration.
|
|
||||||
In that case this component is used to receive a string that is evaluated and processed to output
|
|
||||||
socket structures to open a connection.
|
|
|
@ -1,5 +0,0 @@
|
||||||
#
|
|
||||||
# Component Makefile
|
|
||||||
#
|
|
||||||
COMPONENT_ADD_INCLUDEDIRS := include
|
|
||||||
COMPONENT_SRCDIRS := .
|
|
|
@ -4,8 +4,7 @@ cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
# (Not part of the boilerplate)
|
# (Not part of the boilerplate)
|
||||||
# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection.
|
# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection.
|
||||||
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common
|
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
|
||||||
$ENV{IDF_PATH}/examples/protocols/sockets/socket_addr_from_stdin)
|
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
project(tcp_client)
|
project(tcp_client)
|
||||||
|
|
|
@ -4,8 +4,7 @@ cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
# (Not part of the boilerplate)
|
# (Not part of the boilerplate)
|
||||||
# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection.
|
# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection.
|
||||||
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common
|
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
|
||||||
$ENV{IDF_PATH}/examples/protocols/sockets/socket_addr_from_stdin)
|
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
project(udp_client)
|
project(udp_client)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
echo "- Getting paths of CMakeLists and Makefiles"
|
echo "- Getting paths of CMakeLists and Makefiles"
|
||||||
IFS=
|
IFS=
|
||||||
CMAKELISTS=$( find ${IDF_PATH}/examples/ -type f -name CMakeLists.txt | grep -v "/components/" | grep -v "/common_components/" | grep -v "/cxx/experimental/experimental_cpp_component/" | grep -v "/main/" | grep -v "/build_system/cmake/" | grep -v "/mb_example_common/" | grep -v "/socket_addr_from_stdin/" | sort -n)
|
CMAKELISTS=$( find ${IDF_PATH}/examples/ -type f -name CMakeLists.txt | grep -v "/components/" | grep -v "/common_components/" | grep -v "/cxx/experimental/experimental_cpp_component/" | grep -v "/main/" | grep -v "/build_system/cmake/" | grep -v "/mb_example_common/" | sort -n)
|
||||||
MAKEFILES=$( find ${IDF_PATH}/examples/ -type f -name Makefile | grep -v "/build_system/cmake/" | sort -n)
|
MAKEFILES=$( find ${IDF_PATH}/examples/ -type f -name Makefile | grep -v "/build_system/cmake/" | sort -n)
|
||||||
echo " [DONE]"
|
echo " [DONE]"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue