-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'icd_example/add_uat_button' into 'main'
example: Add user active mode trigger button for icd example Closes CON-1486 See merge request app-frameworks/esp-matter!991
- Loading branch information
Showing
10 changed files
with
85 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
menu "Example Configuration" | ||
config ENABLE_USER_ACTIVE_MODE_TRIGGER_BUTTON | ||
bool "Enable User Active Mode Trigger Button" | ||
default y | ||
help | ||
Enable a button to trigger user active mode, after click this button, the device will keep staying | ||
active for ActiveModeDuration. | ||
|
||
config USER_ACTIVE_MODE_TRIGGER_BUTTON_PIN | ||
int "User Active Mode Trigger Button Pin" | ||
range 9 14 if IDF_TARGET_ESP32H2 | ||
range 0 7 if IDF_TARGET_ESP32C6 | ||
default 9 if IDF_TARGET_ESP32H2 | ||
default 7 if IDF_TARGET_ESP32C6 | ||
help | ||
GPIO number of the active mode trigger button. Note that the boot button of ESP32-C6 DevKits is | ||
GPIO9 which cannot be used to wake up the chip. | ||
|
||
endmenu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <esp_log.h> | ||
#include <esp_matter.h> | ||
#include <iot_button.h> | ||
#include <sdkconfig.h> | ||
|
||
#include <app/icd/server/ICDNotifier.h> | ||
|
||
#include <app_priv.h> | ||
|
||
#ifdef CONFIG_ENABLE_USER_ACTIVE_MODE_TRIGGER_BUTTON | ||
using namespace chip::app::Clusters; | ||
using namespace esp_matter; | ||
|
||
static constexpr char *TAG = "app_driver"; | ||
|
||
static void app_driver_button_toggle_cb(void *arg, void *data) | ||
{ | ||
// The device will stay active mode for Active Mode Threshold | ||
chip::DeviceLayer::PlatformMgr().ScheduleWork([](intptr_t) { | ||
chip::app::ICDNotifier::GetInstance().NotifyNetworkActivityNotification(); | ||
}); | ||
} | ||
|
||
app_driver_handle_t app_driver_button_init() | ||
{ | ||
/* Initialize button */ | ||
button_config_t config; | ||
memset(&config, 0, sizeof(button_config_t)); | ||
config.type = BUTTON_TYPE_GPIO; | ||
config.gpio_button_config.gpio_num = CONFIG_USER_ACTIVE_MODE_TRIGGER_BUTTON_PIN; | ||
config.gpio_button_config.active_level = 0; | ||
config.gpio_button_config.enable_power_save = true; | ||
button_handle_t handle = iot_button_create(&config); | ||
|
||
iot_button_register_cb(handle, BUTTON_PRESS_DOWN, app_driver_button_toggle_cb, NULL); | ||
return (app_driver_handle_t)handle; | ||
} | ||
|
||
#endif // CONFIG_ENABLE_USER_ACTIVE_MODE_TRIGGER_BUTTON |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dependencies: | ||
espressif/button: | ||
version: "^3.4.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
CONFIG_IDF_TARGET="esp32c6" | ||
|
||
CONFIG_ESP_PHY_MAC_BB_PD=y | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters