ajout capteur presence
This commit is contained in:
parent
e8b2be0023
commit
2000e459c9
@ -320,7 +320,6 @@ static EventGroupHandle_t s_wifi_event_group;
|
|||||||
#define EXAMPLE_ESP_MAXIMUM_RETRY 5
|
#define EXAMPLE_ESP_MAXIMUM_RETRY 5
|
||||||
|
|
||||||
#define ESP_WIFI_SAE_MODE WPA3_SAE_PWE_BOTH
|
#define ESP_WIFI_SAE_MODE WPA3_SAE_PWE_BOTH
|
||||||
#define EXAMPLE_H2E_IDENTIFIER CONFIG_ESP_WIFI_PW_ID
|
|
||||||
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_PSK
|
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_PSK
|
||||||
|
|
||||||
static int s_retry_num = 0;
|
static int s_retry_num = 0;
|
||||||
@ -434,7 +433,7 @@ void wifi_init_sta(void)
|
|||||||
*/
|
*/
|
||||||
.threshold.authmode = ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD,
|
.threshold.authmode = ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD,
|
||||||
.sae_pwe_h2e = ESP_WIFI_SAE_MODE,
|
.sae_pwe_h2e = ESP_WIFI_SAE_MODE,
|
||||||
.sae_h2e_identifier = EXAMPLE_H2E_IDENTIFIER,
|
.sae_h2e_identifier = "",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
|
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
|
||||||
|
|||||||
@ -2,7 +2,7 @@ set(EXTRA_COMPONENT_DIRS ../components)
|
|||||||
|
|
||||||
idf_component_register(SRC_DIRS . fonts
|
idf_component_register(SRC_DIRS . fonts
|
||||||
INCLUDE_DIRS "."
|
INCLUDE_DIRS "."
|
||||||
REQUIRES heap nvs_flash meteofrance communication esp_netif image_downloader fatfs sdmmc vfs littlefs wifi_logger protocol_examples_common app_update esp_https_ota bsp_extra esp32_p4_function_ev_board
|
REQUIRES heap nvs_flash meteofrance communication esp_netif image_downloader fatfs sdmmc vfs littlefs wifi_logger protocol_examples_common app_update esp_https_ota bsp_extra esp32_p4_function_ev_board esp_driver_gpio
|
||||||
EMBED_TXTFILES ${project_dir}/main/ca_cert.pem)
|
EMBED_TXTFILES ${project_dir}/main/ca_cert.pem)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
menu "Example Configuration"
|
menu "Domotic Configuration"
|
||||||
|
|
||||||
config ESP_WIFI_SSID
|
config ESP_WIFI_SSID
|
||||||
string "WiFi SSID"
|
string "WiFi SSID"
|
||||||
@ -12,56 +12,11 @@ menu "Example Configuration"
|
|||||||
help
|
help
|
||||||
WiFi password (WPA or WPA2) for the example to use.
|
WiFi password (WPA or WPA2) for the example to use.
|
||||||
|
|
||||||
choice ESP_WIFI_SAE_MODE
|
config GPIO_INPUT_CAPTEUR_PIR
|
||||||
prompt "WPA3 SAE mode selection"
|
int "GPIO PIN Capteur PIR"
|
||||||
default ESP_WPA3_SAE_PWE_BOTH
|
range ENV_GPIO_RANGE_MIN ENV_GPIO_IN_RANGE_MAX
|
||||||
|
default 4
|
||||||
help
|
help
|
||||||
Select mode for SAE as Hunt and Peck, H2E or both.
|
GPIO pin à utiliser pour le capteur de présence IR.
|
||||||
config ESP_WPA3_SAE_PWE_HUNT_AND_PECK
|
|
||||||
bool "HUNT AND PECK"
|
|
||||||
config ESP_WPA3_SAE_PWE_HASH_TO_ELEMENT
|
|
||||||
bool "H2E"
|
|
||||||
config ESP_WPA3_SAE_PWE_BOTH
|
|
||||||
bool "BOTH"
|
|
||||||
endchoice
|
|
||||||
|
|
||||||
config ESP_WIFI_PW_ID
|
|
||||||
string "PASSWORD IDENTIFIER"
|
|
||||||
depends on ESP_WPA3_SAE_PWE_HASH_TO_ELEMENT|| ESP_WPA3_SAE_PWE_BOTH
|
|
||||||
default ""
|
|
||||||
help
|
|
||||||
password identifier for SAE H2E
|
|
||||||
|
|
||||||
config ESP_MAXIMUM_RETRY
|
|
||||||
int "Maximum retry"
|
|
||||||
default 5
|
|
||||||
help
|
|
||||||
Set the Maximum retry to avoid station reconnecting to the AP unlimited when the AP is really inexistent.
|
|
||||||
|
|
||||||
choice ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD
|
|
||||||
prompt "WiFi Scan auth mode threshold"
|
|
||||||
default ESP_WIFI_AUTH_WPA2_PSK
|
|
||||||
help
|
|
||||||
The weakest authmode to accept in the scan mode.
|
|
||||||
This value defaults to ESP_WIFI_AUTH_WPA2_PSK incase password is present and ESP_WIFI_AUTH_OPEN is used.
|
|
||||||
Please select ESP_WIFI_AUTH_WEP/ESP_WIFI_AUTH_WPA_PSK incase AP is operating in WEP/WPA mode.
|
|
||||||
|
|
||||||
config ESP_WIFI_AUTH_OPEN
|
|
||||||
bool "OPEN"
|
|
||||||
config ESP_WIFI_AUTH_WEP
|
|
||||||
bool "WEP"
|
|
||||||
config ESP_WIFI_AUTH_WPA_PSK
|
|
||||||
bool "WPA PSK"
|
|
||||||
config ESP_WIFI_AUTH_WPA2_PSK
|
|
||||||
bool "WPA2 PSK"
|
|
||||||
config ESP_WIFI_AUTH_WPA_WPA2_PSK
|
|
||||||
bool "WPA/WPA2 PSK"
|
|
||||||
config ESP_WIFI_AUTH_WPA3_PSK
|
|
||||||
bool "WPA3 PSK"
|
|
||||||
config ESP_WIFI_AUTH_WPA2_WPA3_PSK
|
|
||||||
bool "WPA2/WPA3 PSK"
|
|
||||||
config ESP_WIFI_AUTH_WAPI_PSK
|
|
||||||
bool "WAPI PSK"
|
|
||||||
endchoice
|
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|||||||
81
main/main.c
81
main/main.c
@ -29,9 +29,11 @@
|
|||||||
#include "image_downloader.h"
|
#include "image_downloader.h"
|
||||||
#include "communication.h"
|
#include "communication.h"
|
||||||
#include "stateManagement.h"
|
#include "stateManagement.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
#include "am2302_rmt.h"
|
#include "am2302_rmt.h"
|
||||||
|
|
||||||
|
#include "esp_timer.h"
|
||||||
|
|
||||||
// GPIO assignment
|
// GPIO assignment
|
||||||
#define AM2302_GPIO 4
|
#define AM2302_GPIO 4
|
||||||
|
|
||||||
@ -237,9 +239,81 @@ void alloc_fail(size_t size, uint32_t caps, const char * function_name){
|
|||||||
ESP_LOGE(TAG,"fail alloc %u in %" PRIu32 " in %s", size,caps,function_name);
|
ESP_LOGE(TAG,"fail alloc %u in %" PRIu32 " in %s", size,caps,function_name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
static QueueHandle_t gpio_evt_queue = NULL;
|
||||||
|
esp_timer_handle_t periodic_timer;
|
||||||
|
|
||||||
|
static void IRAM_ATTR gpio_isr_handler(void* arg)
|
||||||
|
{
|
||||||
|
uint32_t gpio_num = (uint32_t) arg;
|
||||||
|
xQueueSendFromISR(gpio_evt_queue, &gpio_num, NULL);
|
||||||
|
|
||||||
|
}
|
||||||
|
static void gpio_task_example(void* arg)
|
||||||
|
{
|
||||||
|
uint32_t io_num;
|
||||||
|
int delay=50;
|
||||||
|
for (;;) {
|
||||||
|
if (xQueueReceive(gpio_evt_queue, &io_num, portMAX_DELAY)) {
|
||||||
|
ESP_LOGE(TAG,"Got it !");
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
{
|
||||||
|
bsp_display_brightness_set(i);
|
||||||
|
vTaskDelay(delay/portTICK_PERIOD_MS);
|
||||||
|
}
|
||||||
|
//On arrete le timer de presence
|
||||||
|
esp_timer_stop(periodic_timer);
|
||||||
|
//Pour le redemarrer
|
||||||
|
ESP_ERROR_CHECK(esp_timer_start_once(periodic_timer, 10*1000*1000));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#define GPIO_INPUT_IO_0 CONFIG_GPIO_INPUT_CAPTEUR_PIR
|
||||||
|
|
||||||
|
void initPirSensor(){
|
||||||
|
//create a queue to handle gpio event from isr
|
||||||
|
gpio_evt_queue = xQueueCreate(10, sizeof(uint32_t));
|
||||||
|
//start gpio task
|
||||||
|
xTaskCreate(gpio_task_example, "gpio_task_example", 5000, NULL, 10, NULL);
|
||||||
|
|
||||||
|
gpio_config_t gpioconf={
|
||||||
|
.pin_bit_mask= 1ULL<<GPIO_INPUT_IO_0,
|
||||||
|
.intr_type=GPIO_INTR_POSEDGE,
|
||||||
|
.mode=GPIO_MODE_INPUT,
|
||||||
|
.pull_up_en=1
|
||||||
|
};
|
||||||
|
ESP_ERROR_CHECK(gpio_config(&gpioconf));
|
||||||
|
gpio_install_isr_service(0);
|
||||||
|
gpio_isr_handler_add(GPIO_INPUT_IO_0,gpio_isr_handler,(void*)(GPIO_INPUT_IO_0));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ce timer permet d'eteindre l'ecran apres 30s de présence*/
|
||||||
|
static void periodic_timer_callback(void* arg)
|
||||||
|
{
|
||||||
|
int64_t time_since_boot = esp_timer_get_time();
|
||||||
|
ESP_LOGI(TAG, "Periodic timer called, time since boot: %lld us", time_since_boot);
|
||||||
|
for (int i = 100; i >= 0; i--)
|
||||||
|
{
|
||||||
|
bsp_display_brightness_set(i);
|
||||||
|
vTaskDelay(20/portTICK_PERIOD_MS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void app_main(void)
|
void app_main(void)
|
||||||
{
|
{
|
||||||
|
const esp_timer_create_args_t periodic_timer_args = {
|
||||||
|
.callback = &periodic_timer_callback,
|
||||||
|
/* name is optional, but may help identify the timer when debugging */
|
||||||
|
.name = "presence"
|
||||||
|
};
|
||||||
|
ESP_ERROR_CHECK(esp_timer_create(&periodic_timer_args, &periodic_timer));
|
||||||
|
/* Start the timers */
|
||||||
|
ESP_ERROR_CHECK(esp_timer_start_once(periodic_timer, 30*1000*1000));
|
||||||
|
|
||||||
|
|
||||||
|
initPirSensor();
|
||||||
|
|
||||||
printf("Minimum free heap size: %" PRIu32 " bytes\n", esp_get_minimum_free_heap_size());
|
printf("Minimum free heap size: %" PRIu32 " bytes\n", esp_get_minimum_free_heap_size());
|
||||||
printf("Free heap size: %" PRIu32 " bytes\n", esp_get_free_heap_size());
|
printf("Free heap size: %" PRIu32 " bytes\n", esp_get_free_heap_size());
|
||||||
heap_caps_print_heap_info(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
|
heap_caps_print_heap_info(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
|
||||||
@ -378,8 +452,7 @@ void app_main(void)
|
|||||||
|
|
||||||
mqtt_app_start();
|
mqtt_app_start();
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
// Configuration de la sonde Temp/Humid.
|
// Configuration de la sonde Temp/Humid.
|
||||||
am2302_config_t am2302_config = {
|
am2302_config_t am2302_config = {
|
||||||
.gpio_num = AM2302_GPIO,
|
.gpio_num = AM2302_GPIO,
|
||||||
@ -391,7 +464,7 @@ void app_main(void)
|
|||||||
|
|
||||||
|
|
||||||
xTaskCreate(&readTempHumid, "read_temp_task", 8192, NULL, 5, NULL);
|
xTaskCreate(&readTempHumid, "read_temp_task", 8192, NULL, 5, NULL);
|
||||||
|
*/
|
||||||
//xTaskCreate(&simple_ota_example_task, "ota_example_task", 8192, NULL, 5, NULL);
|
//xTaskCreate(&simple_ota_example_task, "ota_example_task", 8192, NULL, 5, NULL);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user