zoukankan      html  css  js  c++  java
  • esp_err_t esp_event_loop_init(system_event_cb_t cb, void *ctx);

    esp_err_t esp_event_loop_init(system_event_cb_t cb, void *ctx)
    {
    if (s_event_init_flag) {
    return ESP_FAIL;
    }
    s_event_handler_cb = cb;
    s_event_ctx = ctx;
    s_event_queue = xQueueCreate(CONFIG_SYSTEM_EVENT_QUEUE_SIZE, sizeof(system_event_t));

    xTaskCreatePinnedToCore(esp_event_loop_task, "eventTask",
    ESP_TASKD_EVENT_STACK, NULL, ESP_TASKD_EVENT_PRIO, NULL, 0);

    s_event_init_flag = true;
    return ESP_OK;
    }

    system_event_cb_t cb 当wifi系统发生状态改变时回调函数 cb

    void *ctx 传给回调函数的参数

    typedef enum {
    SYSTEM_EVENT_WIFI_READY = 0, /**< ESP32 WiFi 准备就绪*/
    SYSTEM_EVENT_SCAN_DONE, /**< ESP32 完成扫描 AP */
    SYSTEM_EVENT_STA_START, /**< ESP32 sta 启动 */
    SYSTEM_EVENT_STA_STOP, /**< ESP32 sta 停止 */
    SYSTEM_EVENT_STA_CONNECTED, /**< ESP32 sta 连接到 AP */
    SYSTEM_EVENT_STA_DISCONNECTED, /**< ESP32 sta 从 AP 断开连接 */
    SYSTEM_EVENT_STA_AUTHMODE_CHANGE, /**< ESP32 sta 所连接的 AP 的授权模式改变了 */
    SYSTEM_EVENT_STA_GOT_IP, /**< ESP32 sta 从 AP 获取到 IP 地址 */
    SYSTEM_EVENT_STA_WPS_ER_SUCCESS, /**< ESP32 sta wps succeeds in enrollee mode */
    SYSTEM_EVENT_STA_WPS_ER_FAILED, /**< ESP32 sta wps fails in enrollee mode */
    SYSTEM_EVENT_STA_WPS_ER_TIMEOUT, /**< ESP32 sta wps timeout in enrollee mode */
    SYSTEM_EVENT_STA_WPS_ER_PIN, /**< ESP32 sta wps pin code in enrollee mode */
    SYSTEM_EVENT_AP_START, /**< ESP32 soft-AP 启动*/
    SYSTEM_EVENT_AP_STOP, /**< ESP32 soft-AP 停止*/
    SYSTEM_EVENT_AP_STACONNECTED, /**< 有 sta 连接到 ESP32 soft-AP */
    SYSTEM_EVENT_AP_STADISCONNECTED, /**< 有 sta 从 ESP32 soft-AP 断开连接 */
    SYSTEM_EVENT_AP_PROBEREQRECVED, /**< soft-AP 接口接收到探测请求报文*/
    SYSTEM_EVENT_AP_STA_GOT_IP6, /**< ESP32 sta/ap 接口获取到 IPv6 地址 */
    SYSTEM_EVENT_ETH_START, /**< ESP32 ethernet start */
    SYSTEM_EVENT_ETH_STOP, /**< ESP32 ethernet stop */
    SYSTEM_EVENT_ETH_CONNECTED, /**< ESP32 ethernet phy link up */
    SYSTEM_EVENT_ETH_DISCONNECTED, /**< ESP32 ethernet phy link down */
    SYSTEM_EVENT_ETH_GOT_IP, /**< ESP32 ethernet got IP from connected AP */
    SYSTEM_EVENT_MAX
    } system_event_id_t;

  • 相关阅读:
    [SPOJ-TTM]To the moon
    [BZOJ1901]Zju2112 Dynamic Rankings
    [算法模板]ST表
    [算法模板]树状数组
    [SPOJ-COT]Count on a tree
    [算法模板]倍增求LCA
    【bzoj 3433】{Usaco2014 Jan} Recording the Moolympics(算法效率--贪心)
    【uva 1152】4 Values Whose Sum is Zero(算法效率--中途相遇法+Hash或STL库)
    【uva 658】It's not a Bug, it's a Feature!(图论--Dijkstra或spfa算法+二进制表示+类“隐式图搜索”)
    【uva 10048】Audiophobia(图论--Floyd算法)
  • 原文地址:https://www.cnblogs.com/whigym/p/9132284.html
Copyright © 2011-2022 走看看