#include "driver/dac.h"
#include "unity.h"
#include "esp_system.h"
-#include "esp_event_loop.h"
+#include "esp_event.h"
#include "esp_wifi.h"
#include "esp_log.h"
#include "nvs_flash.h"
#define DEFAULT_SSID "TEST_SSID"
#define DEFAULT_PWD "TEST_PASS"
-static esp_err_t event_handler(void *ctx, system_event_t *event)
+static void wifi_event_handler(void* arg, esp_event_base_t event_base,
+ int32_t event_id, void* event_data)
{
printf("ev_handle_called.\n");
- switch(event->event_id) {
- case SYSTEM_EVENT_STA_START:
- ESP_LOGI(TAG, "SYSTEM_EVENT_STA_START");
+ switch(event_id) {
+ case WIFI_EVENT_STA_START:
+ ESP_LOGI(TAG, "WIFI_EVENT_STA_START");
//do not actually connect in test case
//;
break;
- case SYSTEM_EVENT_STA_GOT_IP:
- ESP_LOGI(TAG, "SYSTEM_EVENT_STA_GOT_IP");
- ESP_LOGI(TAG, "got ip:%s\n",
- ip4addr_ntoa(&event->event_info.got_ip.ip_info.ip));
- break;
- case SYSTEM_EVENT_STA_DISCONNECTED:
- ESP_LOGI(TAG, "SYSTEM_EVENT_STA_DISCONNECTED");
+ case WIFI_EVENT_STA_DISCONNECTED:
+ ESP_LOGI(TAG, "WIFI_EVENT_STA_DISCONNECTED");
TEST_ESP_OK(esp_wifi_connect());
break;
default:
break;
}
+ return ;
+}
+
+static void ip_event_handler(void* arg, esp_event_base_t event_base,
+ int32_t event_id, void* event_data)
+{
+ ip_event_got_ip_t *event;
+ printf("ev_handle_called.\n");
+ switch(event_id) {
+ case IP_EVENT_STA_GOT_IP:
+ event = (ip_event_got_ip_t*)event_data;
+ ESP_LOGI(TAG, "IP_EVENT_STA_GOT_IP");
+ ESP_LOGI(TAG, "got ip:%s\n", ip4addr_ntoa(&event->ip_info.ip));
+ break;
+ default:
+ break;
+ }
+
+ return ;
+}
+
+static int event_init(void)
+{
+ TEST_ESP_OK(esp_event_loop_create_default());
+ ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL));
+ ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, ESP_EVENT_ANY_ID, &ip_event_handler, NULL));
+ return ESP_OK;
+}
+
+static int event_deinit(void)
+{
+ ESP_ERROR_CHECK(esp_event_handler_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler));
+ ESP_ERROR_CHECK(esp_event_handler_unregister(IP_EVENT, ESP_EVENT_ANY_ID, &ip_event_handler));
return ESP_OK;
}
}
TEST_ESP_OK( r);
tcpip_adapter_init();
- TEST_ESP_OK(esp_event_loop_init(event_handler, NULL));
+ event_init();
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
TEST_ESP_OK(esp_wifi_init(&cfg));
wifi_config_t wifi_config = {
printf("wifi stop...\n");
TEST_ESP_OK( esp_wifi_stop() );
TEST_ESP_OK(esp_wifi_deinit());
+ event_deinit();
nvs_flash_deinit();
//test read value
// See the License for the specific language governing permissions and
// limitations under the License.
-
+#include <string.h>
+#include "esp_log.h"
#include "esp_event.h"
#include "esp_event_legacy.h"
-esp_err_t esp_event_send_noop(system_event_t *event);
+#define TAG "event_send"
+esp_err_t esp_event_send_noop(system_event_t *event);
extern esp_err_t esp_event_send_legacy(system_event_t *event) __attribute__((weak, alias("esp_event_send_noop")));
extern esp_err_t esp_event_send_to_default_loop(system_event_t *event) __attribute((weak, alias("esp_event_send_noop")));
-
esp_err_t esp_event_send_noop(system_event_t *event)
{
return ESP_OK;
}
+static system_event_id_t esp_event_legacy_wifi_event_id(int32_t event_id)
+{
+ switch (event_id) {
+ case WIFI_EVENT_WIFI_READY:
+ return SYSTEM_EVENT_WIFI_READY;
+
+ case WIFI_EVENT_SCAN_DONE:
+ return SYSTEM_EVENT_SCAN_DONE;
+
+ case WIFI_EVENT_STA_START:
+ return SYSTEM_EVENT_STA_START;
+
+ case WIFI_EVENT_STA_STOP:
+ return SYSTEM_EVENT_STA_STOP;
+
+ case WIFI_EVENT_STA_CONNECTED:
+ return SYSTEM_EVENT_STA_CONNECTED;
+
+ case WIFI_EVENT_STA_DISCONNECTED:
+ return SYSTEM_EVENT_STA_DISCONNECTED;
+
+ case WIFI_EVENT_STA_AUTHMODE_CHANGE:
+ return SYSTEM_EVENT_STA_AUTHMODE_CHANGE;
+
+ case WIFI_EVENT_STA_WPS_ER_SUCCESS:
+ return SYSTEM_EVENT_STA_WPS_ER_SUCCESS;
+
+ case WIFI_EVENT_STA_WPS_ER_FAILED:
+ return SYSTEM_EVENT_STA_WPS_ER_FAILED;
+
+ case WIFI_EVENT_STA_WPS_ER_TIMEOUT:
+ return SYSTEM_EVENT_STA_WPS_ER_TIMEOUT;
+
+ case WIFI_EVENT_STA_WPS_ER_PIN:
+ return SYSTEM_EVENT_STA_WPS_ER_PIN;
+
+ case WIFI_EVENT_STA_WPS_ER_PBC_OVERLAP:
+ return SYSTEM_EVENT_STA_WPS_ER_PBC_OVERLAP;
+
+ case WIFI_EVENT_AP_START:
+ return SYSTEM_EVENT_AP_START;
+
+ case WIFI_EVENT_AP_STOP:
+ return SYSTEM_EVENT_AP_STOP;
+
+ case WIFI_EVENT_AP_STACONNECTED:
+ return SYSTEM_EVENT_AP_STACONNECTED;
+
+ case WIFI_EVENT_AP_STADISCONNECTED:
+ return SYSTEM_EVENT_AP_STADISCONNECTED;
+
+ case WIFI_EVENT_AP_PROBEREQRECVED:
+ return SYSTEM_EVENT_AP_PROBEREQRECVED;
+
+ default:
+ ESP_LOGE(TAG, "invalid wifi event id %d", event_id);
+ return SYSTEM_EVENT_MAX;
+ }
+}
+
+static system_event_id_t esp_event_legacy_ip_event_id(int32_t event_id)
+{
+ switch (event_id) {
+ case IP_EVENT_STA_GOT_IP:
+ return SYSTEM_EVENT_STA_GOT_IP;
+
+ case IP_EVENT_STA_LOST_IP:
+ return SYSTEM_EVENT_STA_LOST_IP;
+
+ case IP_EVENT_AP_STAIPASSIGNED:
+ return SYSTEM_EVENT_AP_STAIPASSIGNED;
+
+ case IP_EVENT_GOT_IP6:
+ return SYSTEM_EVENT_GOT_IP6;
+
+ case IP_EVENT_ETH_GOT_IP:
+ return SYSTEM_EVENT_ETH_GOT_IP;
+
+ default:
+ ESP_LOGE(TAG, "invalid ip event id %d", event_id);
+ return SYSTEM_EVENT_MAX;
+ }
+}
+
+
+static system_event_id_t esp_event_legacy_event_id(esp_event_base_t event_base, int32_t event_id)
+{
+ if (event_base == WIFI_EVENT) {
+ return esp_event_legacy_wifi_event_id(event_id);
+ } else if (event_base == IP_EVENT) {
+ return esp_event_legacy_ip_event_id(event_id);
+ } else {
+ ESP_LOGE(TAG, "invalid event base %s", event_base);
+ return SYSTEM_EVENT_MAX;
+ }
+}
+
esp_err_t esp_event_send(system_event_t *event)
{
// send the event to the new style event loop
return ESP_OK;
}
+
+esp_err_t esp_event_send_internal(esp_event_base_t event_base,
+ int32_t event_id,
+ void* event_data,
+ size_t event_data_size,
+ TickType_t ticks_to_wait)
+{
+ system_event_t event;
+
+ // send the event to the new style event loop
+ esp_err_t err = esp_event_post(event_base, event_id, event_data, event_data_size, ticks_to_wait);
+ if (err != ESP_OK) {
+ return err;
+ }
+
+ event.event_id = esp_event_legacy_event_id(event_base, event_id);
+
+ if (event_data) {
+ memcpy(&event.event_info, event_data, event_data_size);
+ }
+
+ return esp_event_send_legacy(&event);
+}
+
} system_event_t;
/** Event handler function type */
-typedef esp_err_t (*system_event_handler_t)(system_event_t *event);
+typedef esp_err_t (*system_event_handler_t)(esp_event_base_t event_base,
+ int32_t event_id,
+ void* event_data,
+ size_t event_data_size,
+ TickType_t ticks_to_wait);
/**
* @brief Send a event to event task
* @return ESP_OK : succeed
* @return others : fail
*/
-esp_err_t esp_event_send(system_event_t *event);
+esp_err_t esp_event_send(system_event_t *event) __attribute__ ((deprecated));
+
+/**
+ * @brief Send a event to event task
+ *
+ * @note This API is used by WiFi Driver only.
+ *
+ * Other task/modules, such as the tcpip_adapter, can call this API to send an event to event task
+ *
+ * @param[in] event_base the event base that identifies the event
+ * @param[in] event_id the event id that identifies the event
+ * @param[in] event_data the data, specific to the event occurence, that gets passed to the handler
+ * @param[in] event_data_size the size of the event data
+ * @param[in] ticks_to_wait number of ticks to block on a full event queue
+ *
+ * @return ESP_OK : succeed
+ * @return others : fail
+ */
+esp_err_t esp_event_send_internal(esp_event_base_t event_base,
+ int32_t event_id,
+ void* event_data,
+ size_t event_data_size,
+ TickType_t ticks_to_wait);
/**
* @brief Default event handler for system events
* @param event pointer to event to be handled
* @return ESP_OK if an event was handled successfully
*/
-esp_err_t esp_event_process_default(system_event_t *event);
+esp_err_t esp_event_process_default(system_event_t *event) __attribute__ ((deprecated));
/**
* @brief Install default event handlers for Ethernet interface
*
* @note This API is part of the legacy event system. New code should use event library API in esp_event.h
*/
-void esp_event_set_default_wifi_handlers(void);
+void esp_event_set_default_wifi_handlers(void) __attribute__ ((deprecated));
/**
* @brief Application specified event callback function
* - ESP_OK: succeed
* - others: fail
*/
-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) __attribute__ ((deprecated));
/**
* @brief Set application specified event callback function
*
* @return old callback
*/
-system_event_cb_t esp_event_loop_set_cb(system_event_cb_t cb, void *ctx);
+system_event_cb_t esp_event_loop_set_cb(system_event_cb_t cb, void *ctx) __attribute__ ((deprecated));
#ifdef __cplusplus
}
-#include "esp_event_legacy.h"
+#pragma once
+#warning "esp_event_loop.h is deprecated, please include esp_event.h instead"
+#include "esp_event.h"
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
-#include "esp_event_loop.h"
+#include "esp_event.h"
#include "freertos/task.h"
#include "freertos/portmacro.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "esp_err.h"
#include "esp_event.h"
-#include "esp_event_loop.h"
#ifdef __cplusplus
extern "C" {
* @brief Parent connected information
*/
typedef struct {
- system_event_sta_connected_t connected; /**< parent information, same as Wi-Fi event SYSTEM_EVENT_STA_CONNECTED does */
+ wifi_event_sta_connected_t connected; /**< parent information, same as Wi-Fi event SYSTEM_EVENT_STA_CONNECTED does */
uint8_t self_layer; /**< layer */
} mesh_event_connected_t;
uint8_t router_bssid[6]; /**< router BSSID */
} mesh_event_find_network_t;
-/**
- * @brief IP settings from LwIP stack
- */
-typedef system_event_sta_got_ip_t mesh_event_root_got_ip_t;
-
/**
* @brief Root address
*/
/**
* @brief Parent disconnected information
*/
-typedef system_event_sta_disconnected_t mesh_event_disconnected_t;
+typedef wifi_event_sta_disconnected_t mesh_event_disconnected_t;
/**
* @brief Child connected information
*/
-typedef system_event_ap_staconnected_t mesh_event_child_connected_t;
+typedef wifi_event_ap_staconnected_t mesh_event_child_connected_t;
/**
* @brief Child disconnected information
*/
-typedef system_event_ap_stadisconnected_t mesh_event_child_disconnected_t;
+typedef wifi_event_ap_stadisconnected_t mesh_event_child_disconnected_t;
/**
* @brief Root switch request information
/**
* @brief New router information
*/
-typedef system_event_sta_connected_t mesh_event_router_switch_t;
+typedef wifi_event_sta_connected_t mesh_event_router_switch_t;
/**
* @brief Mesh event information
packets out. If not, devices had better to wait until this state changes to be
MESH_TODS_REACHABLE. */
mesh_event_vote_started_t vote_started; /**< vote started */
- mesh_event_root_got_ip_t got_ip; /**< root obtains IP address */
+ //mesh_event_root_got_ip_t got_ip; /**< root obtains IP address */
mesh_event_root_address_t root_addr; /**< root address */
mesh_event_root_switch_req_t switch_req; /**< root switch request */
mesh_event_root_conflict_t root_conflict; /**< other powerful root */
-// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
+// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
-// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
+// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
#endif
#define WIFI_INIT_CONFIG_DEFAULT() { \
- .event_handler = &esp_event_send, \
+ .event_handler = &esp_event_send_internal, \
.osi_funcs = &g_wifi_osi_funcs, \
.wpa_crypto_funcs = g_wifi_default_wpa_crypto_funcs, \
.static_rx_buf_num = CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM,\
WIFI_EVENT_AP_STOP, /**< ESP32 soft-AP stop */
WIFI_EVENT_AP_STACONNECTED, /**< a station connected to ESP32 soft-AP */
WIFI_EVENT_AP_STADISCONNECTED, /**< a station disconnected from ESP32 soft-AP */
-
WIFI_EVENT_AP_PROBEREQRECVED, /**< Receive probe request packet in soft-AP interface */
+
+ WIFI_EVENT_MAX, /**< Invalid WiFi event ID */
} wifi_event_t;
/** @cond **/
-Subproject commit 09ed80c2b047ae5bb41ddbfb9be44ec2bc71fedd
+Subproject commit 00ed323d855e71eab0e7cbf114733de92bf0d6bb
#include "esp_system.h"
#include "unity.h"
#include "esp_system.h"
-#include "esp_event_loop.h"
+#include "esp_event.h"
#include "esp_wifi.h"
#include "esp_wifi_types.h"
#include "esp_log.h"
static EventGroupHandle_t wifi_events;
-static esp_err_t event_handler(void *ctx, system_event_t *event)
+static void wifi_event_handler(void* arg, esp_event_base_t event_base,
+ int32_t event_id, void* event_data)
{
- printf("ev_handle_called.\n");
- switch(event->event_id) {
- case SYSTEM_EVENT_STA_START:
- ESP_LOGI(TAG, "SYSTEM_EVENT_STA_START");
+ printf("wifi ev_handle_called.\n");
+ switch(event_id) {
+ case WIFI_EVENT_STA_START:
+ ESP_LOGI(TAG, "WIFI_EVENT_STA_START");
//do not actually connect in test case
//;
break;
- case SYSTEM_EVENT_STA_GOT_IP:
- ESP_LOGI(TAG, "SYSTEM_EVENT_STA_GOT_IP");
- ESP_LOGI(TAG, "got ip:%s\n",
- ip4addr_ntoa(&event->event_info.got_ip.ip_info.ip));
- if (wifi_events) {
- xEventGroupSetBits(wifi_events, GOT_IP_EVENT);
- }
- break;
- case SYSTEM_EVENT_STA_DISCONNECTED:
- ESP_LOGI(TAG, "SYSTEM_EVENT_STA_DISCONNECTED");
+ case WIFI_EVENT_STA_DISCONNECTED:
+ ESP_LOGI(TAG, "WIFI_EVENT_STA_DISCONNECTED");
if (! (EVENT_HANDLER_FLAG_DO_NOT_AUTO_RECONNECT & wifi_event_handler_flag) ) {
TEST_ESP_OK(esp_wifi_connect());
}
default:
break;
}
+ return;
+}
+
+
+static void ip_event_handler(void* arg, esp_event_base_t event_base,
+ int32_t event_id, void* event_data)
+{
+ ip_event_got_ip_t *event;
+
+ printf("ip ev_handle_called.\n");
+ switch(event_id) {
+ case IP_EVENT_STA_GOT_IP:
+ event = (ip_event_got_ip_t*)event_data;
+ ESP_LOGI(TAG, "IP_EVENT_STA_GOT_IP");
+ ESP_LOGI(TAG, "got ip:%s\n",
+ ip4addr_ntoa(&event->ip_info.ip));
+ if (wifi_events) {
+ xEventGroupSetBits(wifi_events, GOT_IP_EVENT);
+ }
+ break;
+ default:
+ break;
+ }
+ return;
+}
+
+static esp_err_t event_init(void)
+{
+ ESP_ERROR_CHECK(esp_event_loop_create_default());
+ ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL));
+ ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, ESP_EVENT_ANY_ID, &ip_event_handler, NULL));
return ESP_OK;
}
ESP_LOGI(TAG, EMPH_STR("tcpip_adapter_init"));
tcpip_adapter_init();
//init event loop
- ESP_LOGI(TAG, EMPH_STR("esp_event_loop_init"));
- TEST_ESP_OK(esp_event_loop_init(event_handler, NULL));
+ ESP_LOGI(TAG, EMPH_STR("event_init"));
+ event_init();
ESP_LOGI(TAG, "test wifi init & deinit...");
test_wifi_init_deinit(&cfg, &wifi_config);
.ap.beacon_interval = 100,
};
- TEST_ESP_OK(esp_event_loop_init(event_handler, NULL));
+ event_init();
// can't deinit event loop, need to reset leak check
unity_reset_leak_checks();
// do not auto connect
wifi_event_handler_flag |= EVENT_HANDLER_FLAG_DO_NOT_AUTO_RECONNECT;
- TEST_ESP_OK(esp_event_loop_init(event_handler, NULL));
+ event_init();
// can't deinit event loop, need to reset leak check
unity_reset_leak_checks();
* @param ctx The system event context
* @param event The system event
*/
-esp_err_t mdns_handle_system_event(void *ctx, system_event_t *event);
+esp_err_t mdns_handle_system_event(void *ctx, system_event_t *event) __attribute__((deprecated));
#ifdef __cplusplus
}
-Subproject commit 117eef2dad54e0f9e25b3005fcfc18e7695ff29e
+Subproject commit fb3d2107cdac440d84f2fab81ea9b5217aa4ba1f
}\
} while(0)
-typedef esp_err_t (*system_event_handler_t)(system_event_t *e);
-
static void handle_ap_start(void *arg, esp_event_base_t base, int32_t event_id, void *data);
static void handle_ap_stop(void *arg, esp_event_base_t base, int32_t event_id, void *data);
static void handle_sta_start(void *arg, esp_event_base_t base, int32_t event_id, void *data);
tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, ð_ip);
if (!(ip4_addr_isany_val(eth_ip.ip) || ip4_addr_isany_val(eth_ip.netmask))) {
- system_event_t evt;
+ ip_event_got_ip_t evt;
//notify event
- evt.event_id = SYSTEM_EVENT_ETH_GOT_IP;
- memcpy(&evt.event_info.got_ip.ip_info, ð_ip, sizeof(tcpip_adapter_ip_info_t));
-
- esp_event_send(&evt);
+ evt.if_index = TCPIP_ADAPTER_IF_ETH;
+ memcpy(&evt.ip_info, ð_ip, sizeof(tcpip_adapter_ip_info_t));
+ API_CALL_CHECK("handle_eth_connected", esp_event_send_internal(IP_EVENT, IP_EVENT_ETH_GOT_IP, &evt, sizeof(evt), 0), ESP_OK);
} else {
ESP_LOGE(TAG, "invalid static ip");
}
tcpip_adapter_get_old_ip_info(TCPIP_ADAPTER_IF_STA, &sta_old_ip);
if (!(ip4_addr_isany_val(sta_ip.ip) || ip4_addr_isany_val(sta_ip.netmask))) {
- system_event_t evt;
+
+ ip_event_got_ip_t evt;
- evt.event_id = SYSTEM_EVENT_STA_GOT_IP;
- evt.event_info.got_ip.ip_changed = false;
+ evt.if_index = TCPIP_ADAPTER_IF_STA;
+ evt.ip_changed = false;
if (memcmp(&sta_ip, &sta_old_ip, sizeof(sta_ip))) {
- evt.event_info.got_ip.ip_changed = true;
+ evt.ip_changed = true;
}
- memcpy(&evt.event_info.got_ip.ip_info, &sta_ip, sizeof(tcpip_adapter_ip_info_t));
+ memcpy(&evt.ip_info, &sta_ip, sizeof(tcpip_adapter_ip_info_t));
tcpip_adapter_set_old_ip_info(TCPIP_ADAPTER_IF_STA, &sta_ip);
- esp_event_send(&evt);
- ESP_LOGD(TAG, "static ip: ip changed=%d", evt.event_info.got_ip.ip_changed);
+ API_CALL_CHECK("handle_sta_connected", esp_event_send_internal(IP_EVENT, IP_EVENT_STA_GOT_IP, &evt, sizeof(evt), 0), ESP_OK);
+ ESP_LOGD(TAG, "static ip: ip changed=%d", evt.ip_changed);
} else {
ESP_LOGE(TAG, "invalid static ip");
}
static void tcpip_adapter_dhcps_cb(u8_t client_ip[4])
{
+ int ret;
+
ESP_LOGI(TAG, "softAP assign IP to station,IP is: %d.%d.%d.%d",
client_ip[0], client_ip[1], client_ip[2], client_ip[3]);
- system_event_t evt;
- memset(&evt, 0, sizeof(system_event_t));
- evt.event_id = SYSTEM_EVENT_AP_STAIPASSIGNED;
- memcpy((char *)&evt.event_info.ap_staipassigned.ip.addr, (char *)client_ip, sizeof(evt.event_info.ap_staipassigned.ip.addr));
- esp_event_send(&evt);
+ ip_event_ap_staipassigned_t evt;
+
+ memset(&evt, 0, sizeof(ip_event_ap_staipassigned_t));
+ memcpy((char *)&evt.ip.addr, (char *)client_ip, sizeof(evt.ip.addr));
+ ret = esp_event_send_internal(IP_EVENT, IP_EVENT_AP_STAIPASSIGNED, &evt, sizeof(evt), 0);
+ if (ESP_OK != ret) {
+ ESP_LOGE(TAG, "dhcps cb: failed to post IP_EVENT_AP_STAIPASSIGNED (%x)", ret);
+ }
}
void tcpip_adapter_init(void)
netif_set_addr(p_netif, &ip_info->ip, &ip_info->netmask, &ip_info->gw);
if (tcpip_if == TCPIP_ADAPTER_IF_STA || tcpip_if == TCPIP_ADAPTER_IF_ETH) {
if (!(ip4_addr_isany_val(ip_info->ip) || ip4_addr_isany_val(ip_info->netmask) || ip4_addr_isany_val(ip_info->gw))) {
- system_event_t evt;
- memset(&evt, 0, sizeof(system_event_t));
- if (tcpip_if == TCPIP_ADAPTER_IF_STA) {
- evt.event_id = SYSTEM_EVENT_STA_GOT_IP;
- } else if (tcpip_if == TCPIP_ADAPTER_IF_ETH) {
- evt.event_id = SYSTEM_EVENT_ETH_GOT_IP;
- }
- evt.event_info.got_ip.ip_changed = false;
+
+ ip_event_t evt_id = IP_EVENT_STA_GOT_IP;
+ ip_event_got_ip_t evt;
+ int ret;
+
+ memset(&evt, 0, sizeof(ip_event_got_ip_t));
+ evt.if_index = tcpip_if;
+ evt.ip_changed = false;
if (memcmp(ip_info, &esp_ip_old[tcpip_if], sizeof(tcpip_adapter_ip_info_t))) {
- evt.event_info.got_ip.ip_changed = true;
+ evt.ip_changed = true;
+ }
+
+ if (tcpip_if == TCPIP_ADAPTER_IF_ETH) {
+ evt_id = IP_EVENT_ETH_GOT_IP;
}
- memcpy(&evt.event_info.got_ip.ip_info, ip_info, sizeof(tcpip_adapter_ip_info_t));
+ memcpy(&evt.ip_info, ip_info, sizeof(tcpip_adapter_ip_info_t));
memcpy(&esp_ip_old[tcpip_if], ip_info, sizeof(tcpip_adapter_ip_info_t));
- esp_event_send(&evt);
- ESP_LOGD(TAG, "if%d tcpip adapter set static ip: ip changed=%d", tcpip_if, evt.event_info.got_ip.ip_changed);
+ ret = esp_event_send_internal(IP_EVENT, evt_id, &evt, sizeof(evt), 0);
+ if (ESP_OK != ret) {
+ ESP_LOGE(TAG, "set ip info: failed to post got ip event (%x)", ret);
+ }
+
+ ESP_LOGD(TAG, "if%d tcpip adapter set static ip: ip changed=%d", tcpip_if, evt.ip_changed);
}
}
}
static void tcpip_adapter_nd6_cb(struct netif *p_netif, uint8_t ip_idex)
{
tcpip_adapter_ip6_info_t *ip6_info;
+ int ret;
- system_event_t evt;
- memset(&evt, 0, sizeof(system_event_t));
+ ip_event_got_ip6_t evt;
+ memset(&evt, 0, sizeof(ip_event_got_ip6_t));
//notify event
- evt.event_id = SYSTEM_EVENT_GOT_IP6;
-
if (!p_netif) {
ESP_LOGD(TAG, "null p_netif=%p", p_netif);
return;
if (p_netif == esp_netif[TCPIP_ADAPTER_IF_STA]) {
ip6_info = &esp_ip6[TCPIP_ADAPTER_IF_STA];
- evt.event_info.got_ip6.if_index = TCPIP_ADAPTER_IF_STA;
+ evt.if_index = TCPIP_ADAPTER_IF_STA;
} else if (p_netif == esp_netif[TCPIP_ADAPTER_IF_AP]) {
ip6_info = &esp_ip6[TCPIP_ADAPTER_IF_AP];
- evt.event_info.got_ip6.if_index = TCPIP_ADAPTER_IF_AP;
+ evt.if_index = TCPIP_ADAPTER_IF_AP;
} else if (p_netif == esp_netif[TCPIP_ADAPTER_IF_ETH]) {
ip6_info = &esp_ip6[TCPIP_ADAPTER_IF_ETH];
- evt.event_info.got_ip6.if_index = TCPIP_ADAPTER_IF_ETH;
+ evt.if_index = TCPIP_ADAPTER_IF_ETH;
} else {
return;
}
ip6_addr_set(&ip6_info->ip, ip_2_ip6(&p_netif->ip6_addr[ip_idex]));
- memcpy(&evt.event_info.got_ip6.ip6_info, ip6_info, sizeof(tcpip_adapter_ip6_info_t));
- esp_event_send(&evt);
+ memcpy(&evt.ip6_info, ip6_info, sizeof(tcpip_adapter_ip6_info_t));
+ ret = esp_event_send_internal(IP_EVENT, IP_EVENT_GOT_IP6, &evt, sizeof(evt), 0);
+ if (ESP_OK != ret) {
+ ESP_LOGE(TAG, "nd6 cb: failed to post IP_EVENT_GOT_IP6 (%x)", ret);
+ }
}
esp_err_t tcpip_adapter_create_ip6_linklocal(tcpip_adapter_if_t tcpip_if)
if ( !ip4_addr_cmp(ip_2_ip4(&netif->ip_addr), (&ip_info->ip)) ||
!ip4_addr_cmp(ip_2_ip4(&netif->netmask), (&ip_info->netmask)) ||
!ip4_addr_cmp(ip_2_ip4(&netif->gw), (&ip_info->gw)) ) {
- system_event_t evt;
- memset(&evt, 0, sizeof(system_event_t));
+ ip_event_got_ip_t evt;
+ ip_event_t evt_id;
+ int ret;
+
+ memset(&evt, 0, sizeof(ip_event_got_ip_t));
ip4_addr_set(&ip_info->ip, ip_2_ip4(&netif->ip_addr));
ip4_addr_set(&ip_info->netmask, ip_2_ip4(&netif->netmask));
ip4_addr_set(&ip_info->gw, ip_2_ip4(&netif->gw));
//notify event
+ evt.if_index = tcpip_if;
if (tcpip_if == TCPIP_ADAPTER_IF_ETH) {
- evt.event_id = SYSTEM_EVENT_ETH_GOT_IP;
- evt.event_info.got_ip.ip_changed = true;
+ evt_id = IP_EVENT_ETH_GOT_IP;
+ evt.ip_changed = true;
} else {
- evt.event_id = SYSTEM_EVENT_STA_GOT_IP;
- evt.event_info.got_ip.ip_changed = false;
+ evt_id = IP_EVENT_STA_GOT_IP;
+ evt.ip_changed = false;
}
if (memcmp(ip_info, ip_info_old, sizeof(tcpip_adapter_ip_info_t))) {
- evt.event_info.got_ip.ip_changed = true;
+ evt.ip_changed = true;
}
- memcpy(&evt.event_info.got_ip.ip_info, ip_info, sizeof(tcpip_adapter_ip_info_t));
+ memcpy(&evt.ip_info, ip_info, sizeof(tcpip_adapter_ip_info_t));
memcpy(ip_info_old, ip_info, sizeof(tcpip_adapter_ip_info_t));
- ESP_LOGD(TAG, "if%d ip changed=%d", tcpip_if, evt.event_info.got_ip.ip_changed);
- esp_event_send(&evt);
+ ESP_LOGD(TAG, "if%d ip changed=%d", tcpip_if, evt.ip_changed);
+ ret = esp_event_send_internal(IP_EVENT, evt_id, &evt, sizeof(evt), 0);
+ if (ESP_OK != ret) {
+ ESP_LOGE(TAG, "dhcpc cb: failed to post got ip event (%x)", ret);
+ }
} else {
ESP_LOGD(TAG, "if%d ip unchanged", tcpip_if);
}
struct netif *netif = esp_netif[tcpip_if];
if ( (!netif) || (netif && ip4_addr_cmp(ip_2_ip4(&netif->ip_addr), IP4_ADDR_ANY4))) {
- system_event_t evt;
- memset(&evt, 0, sizeof(system_event_t));
+ ip_event_got_ip_t evt;
+ int ret;
+ memset(&evt, 0, sizeof(ip_event_got_ip_t));
ESP_LOGD(TAG, "if%d ip lost tmr: raise ip lost event", tcpip_if);
+ evt.if_index = tcpip_if;
memset(&esp_ip_old[tcpip_if], 0, sizeof(tcpip_adapter_ip_info_t));
- evt.event_id = SYSTEM_EVENT_STA_LOST_IP;
- esp_event_send(&evt);
+ ret = esp_event_send_internal(IP_EVENT, IP_EVENT_STA_LOST_IP, &evt, sizeof(evt), 0);
+ if (ESP_OK != ret) {
+ ESP_LOGE(TAG, "ip lost timer: failed to post lost ip event (%x)", ret);
+ }
} else {
ESP_LOGD(TAG, "if%d ip lost tmr: no need raise ip lost event", tcpip_if);
}
#pragma once
-#include <esp_event_loop.h>
#include <protocomm.h>
+#include "esp_event.h"
#include "wifi_provisioning/wifi_config.h"
#ifdef __cplusplus
#pragma once
-#include <esp_event_loop.h>
-
#include <protocomm.h>
#include <protocomm_security.h>
int esp_wifi_set_wps_cb_internal(struct wps_funcs *wps_cb);
bool esp_wifi_enable_sta_privacy_internal(void);
uint8_t esp_wifi_get_user_init_flag_internal(void);
-esp_err_t esp_wifi_send_event_internal(system_event_t *evt);
esp_err_t esp_wifi_internal_supplicant_header_md5_check(const char *md5);
int esp_wifi_sta_update_ap_info_internal(void);
uint8_t *esp_wifi_sta_get_ap_info_prof_pmk_internal(void);
os_bzero(tmpp, 9);
memcpy(tmpp, data->dev_password, 8);
wpa_printf(MSG_DEBUG, "WPS PIN [%s]", tmpp);
- system_event_t evt;
- evt.event_id = SYSTEM_EVENT_STA_WPS_ER_PIN;
- memcpy(evt.event_info.sta_er_pin.pin_code, data->dev_password, 8);
- esp_wifi_send_event_internal(&evt);
+ wifi_event_sta_wps_er_pin_t evt;
+ memcpy(evt.pin_code, data->dev_password, 8);
+ esp_event_send_internal(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_PIN, &evt, sizeof(evt), portMAX_DELAY);
} while (0);
} else if (wps_get_type() == WPS_TYPE_PBC) {
data->pbc = 1;
return wps_tx_start();
}
-int wps_stop_process(system_event_sta_wps_fail_reason_t reason_code)
+int wps_stop_process(wifi_event_sta_wps_fail_reason_t reason_code)
{
struct wps_sm *sm = gWpsSm;
esp_wifi_disconnect();
wpa_printf(MSG_DEBUG, "Write wps_fail_information");
- system_event_t evt;
- evt.event_id = SYSTEM_EVENT_STA_WPS_ER_FAILED;
- evt.event_info.sta_er_fail_reason = reason_code;
- esp_wifi_send_event_internal(&evt);
+
+ esp_event_send_internal(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_FAILED, &reason_code, sizeof(reason_code), portMAX_DELAY);
return ESP_OK;
}
wifi_config_t *config = (wifi_config_t *)os_zalloc(sizeof(wifi_config_t));
if (config == NULL) {
- system_event_t evt;
- evt.event_id = SYSTEM_EVENT_STA_WPS_ER_FAILED;
- esp_wifi_send_event_internal(&evt);
+ esp_event_send_internal(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_FAILED, 0, 0, portMAX_DELAY);
return ESP_FAIL;
}
esp_wifi_disarm_sta_connection_timer_internal();
ets_timer_disarm(&sm->wps_timeout_timer);
- system_event_t evt;
- evt.event_id = SYSTEM_EVENT_STA_WPS_ER_FAILED;
- esp_wifi_send_event_internal(&evt);
+ esp_event_send_internal(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_FAILED, 0, 0, portMAX_DELAY);
return ret;
}
wps_set_status(WPS_STATUS_DISABLE);
- system_event_t evt;
- evt.event_id = SYSTEM_EVENT_STA_WPS_ER_TIMEOUT;
- esp_wifi_send_event_internal(&evt);
+ esp_event_send_internal(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_TIMEOUT, 0, 0, portMAX_DELAY);
}
void wifi_station_wps_timeout(void)
void wifi_station_wps_success_internal(void)
{
- system_event_t evt;
- evt.event_id = SYSTEM_EVENT_STA_WPS_ER_SUCCESS;
- esp_wifi_send_event_internal(&evt);
+ esp_event_send_internal(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_SUCCESS, 0, 0, portMAX_DELAY);
}
void wifi_station_wps_success(void)
} else {
wpa_printf(MSG_INFO, "PBC session overlap!");
wps_set_status(WPS_STATUS_DISABLE);
-
- system_event_t evt;
- evt.event_id = SYSTEM_EVENT_STA_WPS_ER_PBC_OVERLAP;
- esp_wifi_send_event_internal(&evt);
+ esp_event_send_internal(WIFI_EVENT, WIFI_EVENT_STA_WPS_ER_PBC_OVERLAP, 0, 0, portMAX_DELAY);
}
wpa_printf(MSG_DEBUG, "wps scan_done discover_ssid_cnt = %d", sm->discover_ssid_cnt);
#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_wifi.h"
-#include "esp_event_loop.h"
+#include "esp_event.h"
#include "esp_log.h"
#include "nvs_flash.h"
#include "esp_bt.h"
#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_wifi.h"
-#include "esp_event_loop.h"
+#include "esp_event.h"
#include "esp_log.h"
#include "nvs_flash.h"
#include "esp_bt.h"
/* connect infor*/
static uint8_t server_if;
static uint16_t conn_id;
-static esp_err_t example_net_event_handler(void *ctx, system_event_t *event)
+
+static void ip_event_handler(void* arg, esp_event_base_t event_base,
+ int32_t event_id, void* event_data)
{
wifi_mode_t mode;
- switch (event->event_id) {
- case SYSTEM_EVENT_STA_START:
- esp_wifi_connect();
- break;
- case SYSTEM_EVENT_STA_GOT_IP: {
+ switch (event_id) {
+ case IP_EVENT_STA_GOT_IP: {
esp_blufi_extra_info_t info;
xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
esp_blufi_send_wifi_conn_report(mode, ESP_BLUFI_STA_CONN_SUCCESS, 0, &info);
break;
}
- case SYSTEM_EVENT_STA_CONNECTED:
+ default:
+ break;
+ }
+ return;
+}
+
+static void wifi_event_handler(void* arg, esp_event_base_t event_base,
+ int32_t event_id, void* event_data)
+{
+ wifi_event_sta_connected_t *event;
+ wifi_mode_t mode;
+
+ switch (event_id) {
+ case WIFI_EVENT_STA_START:
+ esp_wifi_connect();
+ break;
+ case WIFI_EVENT_STA_CONNECTED:
gl_sta_connected = true;
- memcpy(gl_sta_bssid, event->event_info.connected.bssid, 6);
- memcpy(gl_sta_ssid, event->event_info.connected.ssid, event->event_info.connected.ssid_len);
- gl_sta_ssid_len = event->event_info.connected.ssid_len;
+ event = (wifi_event_sta_connected_t*) event_data;
+ memcpy(gl_sta_bssid, event->bssid, 6);
+ memcpy(gl_sta_ssid, event->ssid, event->ssid_len);
+ gl_sta_ssid_len = event->ssid_len;
break;
- case SYSTEM_EVENT_STA_DISCONNECTED:
+ case WIFI_EVENT_STA_DISCONNECTED:
/* This is a workaround as ESP32 WiFi libs don't currently
auto-reassociate. */
gl_sta_connected = false;
esp_wifi_connect();
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
break;
- case SYSTEM_EVENT_AP_START:
+ case WIFI_EVENT_AP_START:
esp_wifi_get_mode(&mode);
/* TODO: get config or information of softap, then set to report extra_info */
esp_blufi_send_wifi_conn_report(mode, ESP_BLUFI_STA_CONN_FAIL, 0, NULL);
}
break;
- case SYSTEM_EVENT_SCAN_DONE: {
+ case WIFI_EVENT_SCAN_DONE: {
uint16_t apCount = 0;
esp_wifi_scan_get_ap_num(&apCount);
if (apCount == 0) {
default:
break;
}
- return ESP_OK;
+ return;
}
static void initialise_wifi(void)
{
tcpip_adapter_init();
wifi_event_group = xEventGroupCreate();
- ESP_ERROR_CHECK( esp_event_loop_init(example_net_event_handler, NULL) );
+ ESP_ERROR_CHECK(esp_event_loop_create_default());
+ ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL));
+ ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &ip_event_handler, NULL));
+
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_wifi.h"
-#include "esp_event_loop.h"
+#include "esp_event.h"
#include "esp_log.h"
#include "nvs_flash.h"
#include "esp_bt.h"
#include "freertos/event_groups.h"
#include "esp_wifi.h"
#include "tcpip_adapter.h"
-#include "esp_event_loop.h"
#include "iperf.h"
typedef struct {
free(ap_list_buffer);
}
-static esp_err_t event_handler(void *ctx, system_event_t *event)
+static void wifi_event_handler(void* arg, esp_event_base_t event_base,
+ int32_t event_id, void* event_data)
{
- switch (event->event_id) {
- case SYSTEM_EVENT_STA_GOT_IP:
- xEventGroupClearBits(wifi_event_group, DISCONNECTED_BIT);
- xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
- ESP_LOGI(TAG, "got ip");
- break;
- case SYSTEM_EVENT_SCAN_DONE:
+ switch (event_id) {
+ case WIFI_EVENT_SCAN_DONE:
scan_done_handler();
ESP_LOGI(TAG, "sta scan done");
break;
- case SYSTEM_EVENT_STA_CONNECTED:
+ case WIFI_EVENT_STA_CONNECTED:
ESP_LOGI(TAG, "L2 connected");
break;
- case SYSTEM_EVENT_STA_DISCONNECTED:
+ case WIFI_EVENT_STA_DISCONNECTED:
if (reconnect) {
ESP_LOGI(TAG, "sta disconnect, reconnect...");
esp_wifi_connect();
default:
break;
}
- return ESP_OK;
+ return;
+}
+
+static void ip_event_handler(void* arg, esp_event_base_t event_base,
+ int32_t event_id, void* event_data)
+{
+ switch (event_id) {
+ case IP_EVENT_STA_GOT_IP:
+ xEventGroupClearBits(wifi_event_group, DISCONNECTED_BIT);
+ xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
+ ESP_LOGI(TAG, "got ip");
+ break;
+ default:
+ break;
+ }
+ return;
}
void initialise_wifi(void)
tcpip_adapter_init();
wifi_event_group = xEventGroupCreate();
- ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) );
+ ESP_ERROR_CHECK(esp_event_loop_create_default());
+ ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL));
+ ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &ip_event_handler, NULL));
+
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
ESP_ERROR_CHECK( esp_wifi_set_ps(WIFI_PS_MIN_MODEM) ); //must call this
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
-#include "esp_event_loop.h"
#include "esp_event.h"
#include "esp_log.h"
#include "esp_eth.h"
#include "esp_wifi.h"
#include "esp_system.h"
#include "esp_event.h"
-#include "esp_event_loop.h"
#include "nvs_flash.h"
#include "soc/rtc_periph.h"
#include "driver/spi_slave.h"
#include "esp_wifi.h"
#include "esp_system.h"
#include "esp_event.h"
-#include "esp_event_loop.h"
#include "nvs_flash.h"
#include "soc/rtc_periph.h"
#include "driver/spi_master.h"
*/
#include "esp_wifi.h"
-#include "esp_event_loop.h"
+#include "esp_event.h"
#include "esp_log.h"
#include "esp_system.h"
#include "nvs_flash.h"
#include <sys/param.h>
#include "esp_wifi.h"
-#include "esp_event_loop.h"
+#include "esp_event.h"
#include "esp_log.h"
#include "esp_system.h"
#include "esp_spiffs.h"
*/
#include <esp_wifi.h>
-#include <esp_event_loop.h>
+#include <esp_event.h>
#include <esp_log.h>
#include <esp_system.h>
#include <nvs_flash.h>
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
-#include "esp_event_loop.h"
#include "driver/sdmmc_host.h"
#include "driver/gpio.h"
#include "esp_vfs_semihost.h"
*/
#include <esp_wifi.h>
-#include <esp_event_loop.h>
+#include <esp_event.h>
#include <esp_log.h>
#include <esp_system.h>
#include <nvs_flash.h>
#include "esp_wifi.h"
#include "esp_system.h"
#include "nvs_flash.h"
-#include "esp_event_loop.h"
+#include "esp_event.h"
#include "protocol_examples_common.h"
#include "freertos/FreeRTOS.h"
#include "esp_log.h"
#include "esp_websocket_client.h"
#include "esp_event.h"
-#include "esp_event_loop.h"
static const char *TAG = "WEBSOCKET";
static const char *WEBSOCKET_ECHO_ENDPOINT = CONFIG_WEBSOCKET_URI;
#pragma once
-#include <esp_event_loop.h>
-
#include <protocomm_security.h>
#include <wifi_provisioning/wifi_config.h>
#pragma once
-#include <esp_event_loop.h>
-
#include <protocomm_security.h>
#include <wifi_provisioning/wifi_config.h>
#pragma once
-#include <esp_event_loop.h>
+#include <esp_event.h>
#include <protocomm_security.h>
#include <wifi_provisioning/wifi_config.h>
#pragma once
-#include <esp_event_loop.h>
+#include <esp_event.h>
#include <protocomm_security.h>
#include <wifi_provisioning/wifi_config.h>
#define EVENT_SOURCE_H_
#include "esp_event.h"
-#include "esp_event_loop.h"
#include "esp_timer.h"
#ifdef __cplusplus
}
#endif
-#endif // #ifndef EVENT_SOURCE_H_
\ No newline at end of file
+#endif // #ifndef EVENT_SOURCE_H_
#define EVENT_SOURCE_H_
#include "esp_event.h"
-#include "esp_event_loop.h"
#include "esp_timer.h"
#ifdef __cplusplus
}
#endif
-#endif // #ifndef EVENT_SOURCE_H_
\ No newline at end of file
+#endif // #ifndef EVENT_SOURCE_H_
#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_wifi.h"
-#include "esp_event_loop.h"
+#include "esp_event.h"
#include "esp_log.h"
#include "nvs_flash.h"
#include "driver/uart.h"
#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_event.h"
-#include "esp_event_loop.h"
#include "esp_log.h"
#include "esp_ota_ops.h"
#include "esp_http_client.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_event.h"
-#include "esp_event_loop.h"
#include "esp_log.h"
#include "esp_ota_ops.h"
#include "esp_http_client.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_event.h"
-#include "esp_event_loop.h"
#include "esp_log.h"
#include "esp_ota_ops.h"
#include "esp_http_client.h"