Skip to content

Commit 73fc400

Browse files
committed
feat(iot_eth): improve component description
1 parent 29a3eac commit 73fc400

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+422
-4920
lines changed

.github/workflows/upload_component.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ jobs:
5656
components/extended_vfs;
5757
components/gprof;
5858
components/i2c_bus;
59+
components/iot_eth;
5960
components/ir/ir_learn;
6061
components/keyboard_button;
6162
components/knob;
@@ -95,6 +96,7 @@ jobs:
9596
components/usb/iot_usbh_modem;
9697
components/usb/usb_device_uac;
9798
components/usb/usb_device_uvc;
99+
components/usb/usb_host_rndis;
98100
components/usb/usb_stream;
99101
components/utilities/adc_tp_calibration;
100102
components/utilities/xz;

.gitlab/ci/rules.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,10 @@
321321
.patterns-components_usb_usb_device_uvc: &patterns-components_usb_usb_device_uvc
322322
- "components/usb/usb_device_uvc/**/*"
323323

324+
.patterns-components_usb_usb_host_rndis: &patterns-components_usb_usb_host_rndis
325+
- "components/usb/usb_host_rndis/**/*"
326+
- "tools/cmake_utilities/package_manager.cmake"
327+
324328
.patterns-components_usb_usb_stream: &patterns-components_usb_usb_stream
325329
- "components/usb/usb_stream/**/*"
326330
- "tools/cmake_utilities/package_manager.cmake"
@@ -343,6 +347,10 @@
343347
- "components/i2c_bus/**/*"
344348
- "tools/cmake_utilities/package_manager.cmake"
345349

350+
.patterns-components_iot_eth: &patterns-components_iot_eth
351+
- "components/iot_eth/**/*"
352+
- "tools/cmake_utilities/package_manager.cmake"
353+
346354
.patterns-components_sensors_power_monitor_ina236: &patterns-components_sensors_power_monitor_ina236
347355
- "components/sensors/power_monitor/ina236/**/*"
348356
- "tools/cmake_utilities/package_manager.cmake"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ The registered components in ESP-IoT-Solution are listed below:
108108
| [hdc2010](https://components.espressif.com/components/espressif/hdc2010) | [![Component Registry](https://components.espressif.com/components/espressif/hdc2010/badge.svg)](https://components.espressif.com/components/espressif/hdc2010) |
109109
| [i2c_bus](https://components.espressif.com/components/espressif/i2c_bus) | [![Component Registry](https://components.espressif.com/components/espressif/i2c_bus/badge.svg)](https://components.espressif.com/components/espressif/i2c_bus) |
110110
| [ina236](https://components.espressif.com/components/espressif/ina236) | [![Component Registry](https://components.espressif.com/components/espressif/ina236/badge.svg)](https://components.espressif.com/components/espressif/ina236) |
111+
| [iot_eth](https://components.espressif.com/components/espressif/iot_eth) | [![Component Registry](https://components.espressif.com/components/espressif/iot_eth/badge.svg)](https://components.espressif.com/components/espressif/iot_eth) |
111112
| [iot_usbh](https://components.espressif.com/components/espressif/iot_usbh) | [![Component Registry](https://components.espressif.com/components/espressif/iot_usbh/badge.svg)](https://components.espressif.com/components/espressif/iot_usbh) |
112113
| [iot_usbh_cdc](https://components.espressif.com/components/espressif/iot_usbh_cdc) | [![Component Registry](https://components.espressif.com/components/espressif/iot_usbh_cdc/badge.svg)](https://components.espressif.com/components/espressif/iot_usbh_cdc) |
113114
| [iot_usbh_modem](https://components.espressif.com/components/espressif/iot_usbh_modem) | [![Component Registry](https://components.espressif.com/components/espressif/iot_usbh_modem/badge.svg)](https://components.espressif.com/components/espressif/iot_usbh_modem) |
@@ -135,6 +136,7 @@ The registered components in ESP-IoT-Solution are listed below:
135136
| [touch_slider_sensor](https://components.espressif.com/components/espressif/touch_slider_sensor) | [![Component Registry](https://components.espressif.com/components/espressif/touch_slider_sensor/badge.svg)](https://components.espressif.com/components/espressif/touch_slider_sensor) |
136137
| [usb_device_uac](https://components.espressif.com/components/espressif/usb_device_uac) | [![Component Registry](https://components.espressif.com/components/espressif/usb_device_uac/badge.svg)](https://components.espressif.com/components/espressif/usb_device_uac) |
137138
| [usb_device_uvc](https://components.espressif.com/components/espressif/usb_device_uvc) | [![Component Registry](https://components.espressif.com/components/espressif/usb_device_uvc/badge.svg)](https://components.espressif.com/components/espressif/usb_device_uvc) |
139+
| [usb_host_rndis](https://components.espressif.com/components/espressif/usb_host_rndis) | [![Component Registry](https://components.espressif.com/components/espressif/usb_host_rndis/badge.svg)](https://components.espressif.com/components/espressif/usb_host_rndis) |
138140
| [usb_stream](https://components.espressif.com/components/espressif/usb_stream) | [![Component Registry](https://components.espressif.com/components/espressif/usb_stream/badge.svg)](https://components.espressif.com/components/espressif/usb_stream) |
139141
| [veml6040](https://components.espressif.com/components/espressif/veml6040) | [![Component Registry](https://components.espressif.com/components/espressif/veml6040/badge.svg)](https://components.espressif.com/components/espressif/veml6040) |
140142
| [veml6075](https://components.espressif.com/components/espressif/veml6075) | [![Component Registry](https://components.espressif.com/components/espressif/veml6075/badge.svg)](https://components.espressif.com/components/espressif/veml6075) |

README_CN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ ESP-IoT-Solution 中注册的组件如下:
108108
| [hdc2010](https://components.espressif.com/components/espressif/hdc2010) | [![Component Registry](https://components.espressif.com/components/espressif/hdc2010/badge.svg)](https://components.espressif.com/components/espressif/hdc2010) |
109109
| [i2c_bus](https://components.espressif.com/components/espressif/i2c_bus) | [![Component Registry](https://components.espressif.com/components/espressif/i2c_bus/badge.svg)](https://components.espressif.com/components/espressif/i2c_bus) |
110110
| [ina236](https://components.espressif.com/components/espressif/ina236) | [![Component Registry](https://components.espressif.com/components/espressif/ina236/badge.svg)](https://components.espressif.com/components/espressif/ina236) |
111+
| [iot_eth](https://components.espressif.com/components/espressif/iot_eth) | [![Component Registry](https://components.espressif.com/components/espressif/iot_eth/badge.svg)](https://components.espressif.com/components/espressif/iot_eth) |
111112
| [iot_usbh](https://components.espressif.com/components/espressif/iot_usbh) | [![Component Registry](https://components.espressif.com/components/espressif/iot_usbh/badge.svg)](https://components.espressif.com/components/espressif/iot_usbh) |
112113
| [iot_usbh_cdc](https://components.espressif.com/components/espressif/iot_usbh_cdc) | [![Component Registry](https://components.espressif.com/components/espressif/iot_usbh_cdc/badge.svg)](https://components.espressif.com/components/espressif/iot_usbh_cdc) |
113114
| [iot_usbh_modem](https://components.espressif.com/components/espressif/iot_usbh_modem) | [![Component Registry](https://components.espressif.com/components/espressif/iot_usbh_modem/badge.svg)](https://components.espressif.com/components/espressif/iot_usbh_modem) |
@@ -135,6 +136,7 @@ ESP-IoT-Solution 中注册的组件如下:
135136
| [touch_slider_sensor](https://components.espressif.com/components/espressif/touch_slider_sensor) | [![Component Registry](https://components.espressif.com/components/espressif/touch_slider_sensor/badge.svg)](https://components.espressif.com/components/espressif/touch_slider_sensor) |
136137
| [usb_device_uac](https://components.espressif.com/components/espressif/usb_device_uac) | [![Component Registry](https://components.espressif.com/components/espressif/usb_device_uac/badge.svg)](https://components.espressif.com/components/espressif/usb_device_uac) |
137138
| [usb_device_uvc](https://components.espressif.com/components/espressif/usb_device_uvc) | [![Component Registry](https://components.espressif.com/components/espressif/usb_device_uvc/badge.svg)](https://components.espressif.com/components/espressif/usb_device_uvc) |
139+
| [usb_host_rndis](https://components.espressif.com/components/espressif/usb_host_rndis) | [![Component Registry](https://components.espressif.com/components/espressif/usb_host_rndis/badge.svg)](https://components.espressif.com/components/espressif/usb_host_rndis) |
138140
| [usb_stream](https://components.espressif.com/components/espressif/usb_stream) | [![Component Registry](https://components.espressif.com/components/espressif/usb_stream/badge.svg)](https://components.espressif.com/components/espressif/usb_stream) |
139141
| [veml6040](https://components.espressif.com/components/espressif/veml6040) | [![Component Registry](https://components.espressif.com/components/espressif/veml6040/badge.svg)](https://components.espressif.com/components/espressif/veml6040) |
140142
| [veml6075](https://components.espressif.com/components/espressif/veml6075) | [![Component Registry](https://components.espressif.com/components/espressif/veml6075/badge.svg)](https://components.espressif.com/components/espressif/veml6075) |

components/iot_eth/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# ChangeLog
2+
3+
## v0.1.0 - 2025-04-22
4+
5+
* publish official version

components/iot_eth/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
idf_component_register(SRCS "iot_eth.c"
22
INCLUDE_DIRS "include" "interface"
33
REQUIRES esp_netif)
4+
5+
include(package_manager)
6+
cu_pkg_define_version(${CMAKE_CURRENT_LIST_DIR})
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: "0.1.0"
2+
description: Ethernet driver for USB Ethernet adapter
3+
url: https://github.com/espressif/esp-iot-solution/tree/master/components/iot_eth
4+
repository: https://github.com/espressif/esp-iot-solution.git
5+
issues: https://github.com/espressif/esp-iot-solution/issues
6+
examples:
7+
- path: ../../examples/usb/host/usb_rndis_4g_module
8+
dependencies:
9+
idf: ">=4.4"
10+
cmake_utilities: "*"
11+
sbom:
12+
supplier: 'Organization: Espressif Systems (Shanghai) CO LTD'
13+
originator: 'Organization: Espressif Systems (Shanghai) CO LTD'

components/iot_eth/include/iot_eth.h

Lines changed: 88 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,109 @@
1212
extern "C" {
1313
#endif
1414

15+
/**
16+
* @brief Ethernet handle type
17+
*
18+
* This is a handle to an Ethernet instance, used for managing Ethernet operations.
19+
*/
1520
typedef void *iot_eth_handle_t;
1621

22+
/**
23+
* @brief Ethernet configuration structure
24+
*
25+
* This structure holds the configuration for initializing an Ethernet instance.
26+
*/
1727
typedef struct {
18-
iot_eth_driver_t *driver;
19-
esp_err_t (*on_lowlevel_init_done)(iot_eth_handle_t handle);
20-
esp_err_t (*on_lowlevel_deinit)(iot_eth_handle_t handle);
21-
esp_err_t (*stack_input)(iot_eth_handle_t handle, uint8_t *data, size_t len, void *user_data);
22-
void *user_data;
28+
iot_eth_driver_t *driver; /*!< Pointer to the Ethernet driver */
29+
esp_err_t (*on_lowlevel_init_done)(iot_eth_handle_t handle); /*!< Callback for low-level initialization completion */
30+
esp_err_t (*on_lowlevel_deinit)(iot_eth_handle_t handle); /*!< Callback for low-level deinitialization */
31+
esp_err_t (*stack_input)(iot_eth_handle_t handle, uint8_t *data, size_t len, void *user_data); /*!< Function pointer for stack input */
32+
void *user_data; /*!< User data for callbacks */
2333
} iot_eth_config_t;
2434

35+
/*
36+
* @brief Install Ethernet driver
37+
*
38+
* This function initializes the Ethernet driver and network interface.
39+
*
40+
* @param config Ethernet configuration
41+
* @param handle Pointer to the Ethernet handle
42+
*
43+
* @return
44+
* - ESP_OK on success
45+
* - ESP_ERR_INVALID_ARG if arguments are invalid
46+
* - ESP_ERR_NO_MEM if memory allocation fails
47+
* - Other error codes from initialization functions
48+
*/
2549
esp_err_t iot_eth_install(iot_eth_config_t *config, iot_eth_handle_t *handle);
2650

51+
/*
52+
* @brief Uninstall Ethernet driver
53+
*
54+
* This function deinitializes the Ethernet driver and frees resources.
55+
*
56+
* @param handle Ethernet handle
57+
*
58+
* @return
59+
* - ESP_OK on success
60+
* - Error code from driver deinitialization
61+
*/
2762
esp_err_t iot_eth_uninstall(iot_eth_handle_t handle);
2863

64+
/*
65+
* @brief Start Ethernet driver
66+
*
67+
* This function starts the Ethernet driver.
68+
*
69+
* @param handle Ethernet handle
70+
*
71+
* @return
72+
* - ESP_OK on success
73+
* - Error code from driver start function
74+
*/
2975
esp_err_t iot_eth_start(iot_eth_handle_t handle);
3076

77+
/*
78+
* @brief Stop Ethernet driver
79+
*
80+
* This function stops the Ethernet driver.
81+
*
82+
* @param handle Ethernet handle
83+
*
84+
* @return
85+
* - ESP_OK on success
86+
* - Error code from driver stop function
87+
*/
3188
esp_err_t iot_eth_stop(iot_eth_handle_t handle);
3289

90+
/*
91+
* @brief Transmit data over Ethernet
92+
*
93+
* This function sends data through the Ethernet driver.
94+
*
95+
* @param handle Ethernet handle
96+
* @param data Pointer to the data to be sent
97+
* @param len Length of the data to be sent
98+
*
99+
* @return
100+
* - ESP_OK on success
101+
* - ESP_ERR_INVALID_ARG if arguments are invalid
102+
* - ESP_ERR_INVALID_STATE if Ethernet link is down
103+
*/
33104
esp_err_t iot_eth_transmit(iot_eth_handle_t handle, uint8_t *data, size_t len);
34105

106+
/*
107+
* @brief Get Ethernet MAC address
108+
*
109+
* This function retrieves the MAC address of the Ethernet interface.
110+
*
111+
* @param handle Ethernet handle
112+
* @param mac Pointer to the MAC address buffer
113+
*
114+
* @return
115+
* - ESP_OK on success
116+
* - Error code from driver get address function
117+
*/
35118
esp_err_t iot_eth_get_addr(iot_eth_handle_t handle, uint8_t *mac);
36119

37120
#ifdef __cplusplus

components/iot_eth/iot_eth.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ esp_err_t iot_eth_on_stage_changed(iot_eth_mediator_t *mediator, iot_eth_stage_t
130130

131131
esp_err_t iot_eth_install(iot_eth_config_t *config, iot_eth_handle_t *handle)
132132
{
133+
ESP_LOGI(TAG, "IoT ETH Version: %d.%d.%d", IOT_ETH_VER_MAJOR, IOT_ETH_VER_MINOR, IOT_ETH_VER_PATCH);
133134
ESP_RETURN_ON_FALSE(config != NULL, ESP_ERR_INVALID_ARG, TAG, "config is NULL");
134135
ESP_RETURN_ON_FALSE(handle != NULL, ESP_ERR_INVALID_ARG, TAG, "handle is NULL");
135136

@@ -156,24 +157,19 @@ esp_err_t iot_eth_install(iot_eth_config_t *config, iot_eth_handle_t *handle)
156157
ret = esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &iot_eth_got_ip_event_handler, NULL);
157158
ESP_GOTO_ON_FALSE(ret == ESP_OK, ESP_FAIL, err, TAG, "Failed to register event handler");
158159

159-
printf("555\n");
160-
161160
eth->stack_input = iot_eth_stack_input_default;
162161
// Prepare network interface for the driver
163162
esp_netif_config_t netif_cfg = ESP_NETIF_DEFAULT_ETH();
164163
eth->netif = esp_netif_new(&netif_cfg);
165-
printf("666\n");
166164
ESP_RETURN_ON_FALSE(eth->netif != NULL, ESP_ERR_NO_MEM, TAG, "Failed to create netif");
167165
esp_netif_driver_ifconfig_t driver_ifconfig = {
168166
.handle = eth,
169167
.transmit = iot_eth_transmit_default,
170168
.driver_free_rx_buffer = iot_eth_free_rx_buffer,
171169
};
172-
printf("777\n");
173170

174171
ret = esp_netif_set_driver_config(eth->netif, &driver_ifconfig);
175172
ESP_GOTO_ON_FALSE(ret == ESP_OK, ESP_FAIL, err, TAG, "Failed to set driver config");
176-
printf("888\n");
177173
esp_netif_set_hostname(eth->netif, eth->driver->name);
178174
} else {
179175
eth->stack_input = config->stack_input;

0 commit comments

Comments
 (0)