diff --git a/components/esp_matter/esp_matter.h b/components/esp_matter/esp_matter.h index 794a6b312..0ec20461e 100644 --- a/components/esp_matter/esp_matter.h +++ b/components/esp_matter/esp_matter.h @@ -24,6 +24,7 @@ application. #include #include #include +#include #include #include diff --git a/components/esp_matter/esp_matter_event.cpp b/components/esp_matter/esp_matter_event.cpp new file mode 100644 index 000000000..77ce7fb87 --- /dev/null +++ b/components/esp_matter/esp_matter_event.cpp @@ -0,0 +1,237 @@ +// Copyright 2022 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. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include + +#include + +static const char *TAG = "esp_matter_event"; + +using chip::DeviceLayer::DeviceControlServer; +using chip::DeviceLayer::SwitchDeviceControlDelegate; + +/** cluster: DoorLock */ +esp_err_t esp_matter_event_send_door_lock_alarm() +{ + /* Not implemented */ + return ESP_OK; +} + +esp_err_t esp_matter_event_send_door_state_change() +{ + /* Not implemented */ + return ESP_OK; +} + +esp_err_t esp_matter_event_send_lock_operation() +{ + /* Not implemented */ + return ESP_OK; +} + +esp_err_t esp_matter_event_send_lock_operation_error() +{ + /* Not implemented */ + return ESP_OK; +} + +esp_err_t esp_matter_event_send_lock_user_change() +{ + /* Not implemented */ + return ESP_OK; +} + +/** cluster: PumpConfigurationAndControl */ +esp_err_t esp_matter_event_send_supply_voltage_low() +{ + /* Not implemented */ + return ESP_OK; +} + +esp_err_t esp_matter_event_send_supply_voltage_high() +{ + /* Not implemented */ + return ESP_OK; +} + +esp_err_t esp_matter_event_send_power_missing_phase() +{ + /* Not implemented */ + return ESP_OK; +} + +esp_err_t esp_matter_event_send_system_pressure_low() +{ + /* Not implemented */ + return ESP_OK; +} + +esp_err_t esp_matter_event_send_system_pressure_high() +{ + /* Not implemented */ + return ESP_OK; +} + +esp_err_t esp_matter_event_send_dry_running() +{ + /* Not implemented */ + return ESP_OK; +} + +esp_err_t esp_matter_event_send_motor_temperature_high() +{ + /* Not implemented */ + return ESP_OK; +} + +esp_err_t esp_matter_event_send_pump_motor_fatal_failure() +{ + /* Not implemented */ + return ESP_OK; +} + +esp_err_t esp_matter_event_send_electronic_temperature_high() +{ + /* Not implemented */ + return ESP_OK; +} + +esp_err_t esp_matter_event_send_pump_blocked() +{ + /* Not implemented */ + return ESP_OK; +} + +esp_err_t esp_matter_event_send_sensor_failure() +{ + /* Not implemented */ + return ESP_OK; +} + +esp_err_t esp_matter_event_send_electronic_non_fatal_failure() +{ + /* Not implemented */ + return ESP_OK; +} + +esp_err_t esp_matter_event_send_electronic_fatal_failure() +{ + /* Not implemented */ + return ESP_OK; +} + +esp_err_t esp_matter_event_send_general_fault() +{ + /* Not implemented */ + return ESP_OK; +} + +esp_err_t esp_matter_event_send_leakage() +{ + /* Not implemented */ + return ESP_OK; +} + +esp_err_t esp_matter_event_send_air_detection() +{ + /* Not implemented */ + return ESP_OK; +} + +esp_err_t esp_matter_event_send_turbine_operation() +{ + /* Not implemented */ + return ESP_OK; +} + +/* cluster: Switch */ +static SwitchDeviceControlDelegate *get_switch_delegate() +{ + SwitchDeviceControlDelegate *delegate = DeviceControlServer::DeviceControlSvr().GetSwitchDelegate(); + if (!delegate) { + ESP_LOGE(TAG, "No delegate registered to handle switch events"); + } + return delegate; +} + +esp_err_t esp_matter_event_send_switch_latched(uint8_t new_position) +{ + SwitchDeviceControlDelegate *delegate = get_switch_delegate(); + if (!delegate) { + return ESP_FAIL; + } + delegate->OnSwitchLatched(new_position); + return ESP_OK; +} + +esp_err_t esp_matter_event_send_initial_press(uint8_t new_position) +{ + SwitchDeviceControlDelegate *delegate = get_switch_delegate(); + if (!delegate) { + return ESP_FAIL; + } + delegate->OnInitialPressed(new_position); + return ESP_OK; +} + +esp_err_t esp_matter_event_send_long_press(uint8_t new_position) +{ + SwitchDeviceControlDelegate *delegate = get_switch_delegate(); + if (!delegate) { + return ESP_FAIL; + } + delegate->OnLongPressed(new_position); + return ESP_OK; +} + +esp_err_t esp_matter_event_send_short_release(uint8_t previous_position) +{ + SwitchDeviceControlDelegate *delegate = get_switch_delegate(); + if (!delegate) { + return ESP_FAIL; + } + delegate->OnShortReleased(previous_position); + return ESP_OK; +} + +esp_err_t esp_matter_event_send_long_release(uint8_t previous_position) +{ + SwitchDeviceControlDelegate *delegate = get_switch_delegate(); + if (!delegate) { + return ESP_FAIL; + } + delegate->OnLongReleased(previous_position); + return ESP_OK; +} + +esp_err_t esp_matter_event_send_multi_press_ongoing(uint8_t new_position, uint8_t count) +{ + SwitchDeviceControlDelegate *delegate = get_switch_delegate(); + if (!delegate) { + return ESP_FAIL; + } + delegate->OnMultiPressOngoing(new_position, count); + return ESP_OK; +} + +esp_err_t esp_matter_event_send_multi_press_complete(uint8_t new_position, uint8_t count) +{ + SwitchDeviceControlDelegate *delegate = get_switch_delegate(); + if (!delegate) { + return ESP_FAIL; + } + delegate->OnMultiPressComplete(new_position, count); + return ESP_OK; +} diff --git a/components/esp_matter/esp_matter_event.h b/components/esp_matter/esp_matter_event.h new file mode 100644 index 000000000..4ce43714f --- /dev/null +++ b/components/esp_matter/esp_matter_event.h @@ -0,0 +1,31 @@ +// Copyright 2022 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. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include + +/** + * NOTE: These events are currently sent on all the endpoints where the corresponding cluster exists. + * Once this behaviour is changed, the event APIs here would have the endpoint_id as an argument. + * Issue: https://github.com/project-chip/connectedhomeip/issues/14624 +*/ + +esp_err_t esp_matter_event_send_switch_latched(uint8_t new_position); +esp_err_t esp_matter_event_send_initial_press(uint8_t new_position); +esp_err_t esp_matter_event_send_long_press(uint8_t new_position); +esp_err_t esp_matter_event_send_short_release(uint8_t previous_position); +esp_err_t esp_matter_event_send_long_release(uint8_t previous_position); +esp_err_t esp_matter_event_send_multi_press_ongoing(uint8_t new_position, uint8_t count); +esp_err_t esp_matter_event_send_multi_press_complete(uint8_t new_position, uint8_t count);