void*ctx:这个参数是应用程序指定的,在调用esp_event_loop_init的第二个参数。 system_event_t *event: 指向系统事件(状态机的状态),包括状态ID, 状态信息,结构如下: typedef struct { system_event_id_t event_id; /**< event ID */ system_event_info_t event_info; /**< event information */ } ...
这里需要看两个函数的函数原型,其中一个是esp_event_loop_init(),另一个是需要传递给该函数的回调函数(callback)。 先看esp_event_loop_init(): /** * @brief Initialize event loop * Create the event handler and task * * @param system_event_cb_t cb : application specified event callback, it ...
udp_event_group =xEventGroupCreate();tcpip_adapter_init();ESP_ERROR_CHECK(esp_event_loop_init(event_handler,NULL));wifi_init_config_tcfg =WIFI_INIT_CONFIG_DEFAULT();ESP_ERROR_CHECK(esp_wifi_init(&cfg));wifi_config_twifi_config = { .sta = { .ssid = GATEWAY_SSID, .password = GATEW...
If I replace esp_event_loop_create_default with esp_event_loop_init(nullptr, nullptr), which I understand is deprecated, the error goes away and everything still works fine. The strangest thing is that when I created a new project to test this, neither esp_event_loop_create_default nor ...
xEventGroupSetBits(wifi_event_group, ESPTOUCH_DONE_BIT); 1 注意点②:在esp_event_loop_init()设置的回调事件,是一个设置轮询在回调的方法,在其的方法回调中,拦截了三个状态:SYSTEM_EVENT_STA_START、SYSTEM_EVENT_STA_GOT_IP和SYSTEM_EVENT_STA_DISCONNECTED,后面的系统断开连接回调,估计只是为了适配这个demo...
If you're calling this wifi_init_sta() function more than once between two reboots, a) you should not call esp_event_loop_create_default()insidethat function and b) you have a memory leak the size of one event group per call.
Many components depend on the event loop being initialised, so you should do it once early in your main initialisation. Repeated calls will return ESP_ERR_INVALID_STATE. Is there another esp_event_loop_create_default() somewhere before this wifiInit()?
ESP_ERROR_CHECK(esp_event_loop_create_default()); esp_netif_t *sta_netif = esp_netif_create_default_wifi_sta(); assert(sta_netif); wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); ESP_ERROR_CHECK( esp_wifi_init(&cfg) ); ESP_ERROR_CHECK( esp_event_handler_reg...
一般不需要特别配置,直接使用函数tcpip_adapter_init(); 1.2设置事件回调函数 ESP32WIFI启动的时候会产生很多事件回调,这些事件的都绑定在一个回调函数上,在函数内通过判断传递的参数来判断事件类型。 esp_event_loop_init(event_handler, NULL); 1.3wifi配置初始化与设置 ...
调用esp_event_loop_create_default()创建默认事件循环。之后使用esp_event_handler_register()将事件处理程序注册到系统事件循环,详情见上一小节 1.3 WiFi事件的注册、响应、信息获取 部分。 在示例中: 在这里插入图片描述 初始化WiFi 和 配置WiFi 使用esp_wifi_init进行 WiFi 初始化。 在示例中,先是使用了默认配...