new buzzer component
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
set(srcs
|
||||
"src/wifi.c")
|
||||
"src/network_events.c"
|
||||
"src/network.c"
|
||||
)
|
||||
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS "include"
|
||||
PRIV_REQUIRES nvs_flash esp_netif esp_wifi mdns)
|
||||
PRIV_REQUIRES nvs_flash esp_netif esp_wifi mdns esp_event)
|
||||
24
components/network/include/network_events.h
Normal file
24
components/network/include/network_events.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "esp_event.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Declaração do base de eventos personalizados da rede
|
||||
ESP_EVENT_DECLARE_BASE(NETWORK_EVENTS);
|
||||
|
||||
// Identificadores dos eventos possíveis do módulo network
|
||||
typedef enum {
|
||||
NETWORK_EVENT_AP_STARTED,
|
||||
NETWORK_EVENT_AP_STOP,
|
||||
NETWORK_EVENT_STA_CONNECTED,
|
||||
NETWORK_EVENT_STA_DISCONNECTED,
|
||||
NETWORK_EVENT_STA_GOT_IP,
|
||||
NETWORK_EVENT_STA_LOST_IP
|
||||
} network_event_id_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -10,7 +10,9 @@
|
||||
#include "nvs.h"
|
||||
#include "mdns.h"
|
||||
|
||||
#include "wifi.h"
|
||||
#include "network_events.h"
|
||||
#include "network.h"
|
||||
|
||||
|
||||
#define AP_SSID "plx-%02x%02x%02x"
|
||||
|
||||
@@ -292,6 +294,8 @@ void wifi_ap_start(void)
|
||||
{
|
||||
ESP_LOGI(TAG, "Starting AP");
|
||||
|
||||
esp_event_post(NETWORK_EVENTS, NETWORK_EVENT_AP_STARTED, NULL, 0, portMAX_DELAY);
|
||||
|
||||
xEventGroupClearBits(wifi_event_group, WIFI_STA_MODE_BIT);
|
||||
esp_wifi_stop();
|
||||
|
||||
@@ -304,6 +308,9 @@ void wifi_ap_start(void)
|
||||
void wifi_ap_stop(void)
|
||||
{
|
||||
ESP_LOGI(TAG, "Stopping AP");
|
||||
|
||||
esp_event_post(NETWORK_EVENTS, NETWORK_EVENT_AP_STOP, NULL, 0, portMAX_DELAY);
|
||||
|
||||
xEventGroupClearBits(wifi_event_group, WIFI_AP_MODE_BIT);
|
||||
esp_wifi_stop();
|
||||
|
||||
4
components/network/src/network_events.c
Normal file
4
components/network/src/network_events.c
Normal file
@@ -0,0 +1,4 @@
|
||||
#include "network_events.h"
|
||||
|
||||
// Define o base de eventos
|
||||
ESP_EVENT_DEFINE_BASE(NETWORK_EVENTS);
|
||||
Reference in New Issue
Block a user