66#pragma once
77
88#include "esp_err.h"
9+ #include "esp_event.h"
910#include "iot_eth_interface.h"
1011
1112#ifdef __cplusplus
1213extern "C" {
1314#endif
1415
16+ /**
17+ * @brief iot_eth event declarations
18+ *
19+ */
20+ typedef enum {
21+ IOT_ETH_EVENT_START , /*!< IOT_ETH driver start */
22+ IOT_ETH_EVENT_STOP , /*!< IOT_ETH driver stop */
23+ IOT_ETH_EVENT_CONNECTED , /*!< IOT_ETH got a valid link */
24+ IOT_ETH_EVENT_DISCONNECTED , /*!< IOT_ETH lost a valid link */
25+ } iot_eth_event_t ;
26+
27+ /**
28+ * @brief iot_eth event base declaration
29+ *
30+ */
31+ /** @cond **/
32+ ESP_EVENT_DECLARE_BASE (IOT_ETH_EVENT );
33+ /** @endcond **/
34+
1535/**
1636 * @brief Ethernet handle type
1737 *
1838 * This is a handle to an Ethernet instance, used for managing Ethernet operations.
1939 */
2040typedef void * iot_eth_handle_t ;
2141
42+ /**
43+ * @brief Static input callback function type
44+ *
45+ * This type defines a function pointer for a static input callback.
46+ * It takes an Ethernet handle, a pointer to data, the length of the data,
47+ * and a user data pointer as arguments.
48+ */
49+ typedef esp_err_t (* static_input_cb_t )(iot_eth_handle_t handle , uint8_t * data , size_t len , void * user_data );
50+
2251/**
2352 * @brief Ethernet configuration structure
2453 *
2554 * This structure holds the configuration for initializing an Ethernet instance.
2655 */
2756typedef struct {
2857 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 */
58+ static_input_cb_t stack_input ; /*!< Function pointer for stack input */
3259 void * user_data ; /*!< User data for callbacks */
3360} iot_eth_config_t ;
3461
@@ -101,7 +128,7 @@ esp_err_t iot_eth_stop(iot_eth_handle_t handle);
101128 * - ESP_ERR_INVALID_ARG if arguments are invalid
102129 * - ESP_ERR_INVALID_STATE if Ethernet link is down
103130 */
104- esp_err_t iot_eth_transmit (iot_eth_handle_t handle , uint8_t * data , size_t len );
131+ esp_err_t iot_eth_transmit (iot_eth_handle_t handle , void * data , size_t len );
105132
106133/*
107134 * @brief Get Ethernet MAC address
@@ -117,6 +144,22 @@ esp_err_t iot_eth_transmit(iot_eth_handle_t handle, uint8_t *data, size_t len);
117144 */
118145esp_err_t iot_eth_get_addr (iot_eth_handle_t handle , uint8_t * mac );
119146
147+ /*
148+ * @brief Update the input path for Ethernet data
149+ *
150+ * This function updates the stack input callback function and user data pointer
151+ * that will be used when receiving Ethernet packets.
152+ *
153+ * @param[in] handle Ethernet handle
154+ * @param[in] stack_input Function pointer for stack input callback
155+ * @param[in] user_data User data to be passed to stack input callback
156+ *
157+ * @return
158+ * - ESP_OK: Successfully updated input path
159+ * - ESP_ERR_INVALID_ARG: Invalid handle argument
160+ */
161+ esp_err_t iot_eth_update_input_path (iot_eth_handle_t handle , static_input_cb_t stack_input , void * user_data );
162+
120163#ifdef __cplusplus
121164}
122165#endif
0 commit comments