-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c9fd87
commit 518d63c
Showing
11 changed files
with
290 additions
and
0 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
74 changes: 74 additions & 0 deletions
74
applications/zpc/components/zcl_cluster_servers/src/fan_control_cluster_server.c
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,74 @@ | ||
|
||
/****************************************************************************** | ||
* # License | ||
* <b>Copyright 2021 Silicon Laboratories Inc. www.silabs.com</b> | ||
****************************************************************************** | ||
* The licensor of this software is Silicon Laboratories Inc. Your use of this | ||
* software is governed by the terms of Silicon Labs Master Software License | ||
* Agreement (MSLA) available at | ||
* www.silabs.com/about-us/legal/master-software-license-agreement. This | ||
* software is distributed to you in Source Code format and is governed by the | ||
* sections of the MSLA applicable to Source Code. | ||
* | ||
*****************************************************************************/ | ||
// Includes from this component | ||
#include "fan_control_cluster_server.h" | ||
|
||
// Includes from Unify | ||
#include "sl_log.h" | ||
#include "sl_status.h" | ||
#include "attribute_store_helper.h" | ||
#include "zpc_attribute_store_network_helper.h" | ||
#include "zwave_command_class_thermostat_fan_types.h" | ||
|
||
#include "attribute_store_defined_attribute_types.h" | ||
#include "unify_dotdot_defined_attribute_types.h" | ||
#include "unify_dotdot_attribute_store.h" | ||
#include "unify_dotdot_attribute_store_node_state.h" | ||
|
||
// Includes from auto-generated files | ||
#include "dotdot_mqtt.h" | ||
|
||
// Setup Log ID | ||
#define LOG_TAG "fan_control_cluster_server" | ||
|
||
sl_status_t | ||
zwave_fan_control_turn_off(dotdot_unid_t unid, | ||
dotdot_endpoint_id_t endpoint, | ||
uic_mqtt_dotdot_callback_call_type_t call_type) | ||
{ | ||
attribute_store_node_t endpoint_node | ||
= attribute_store_network_helper_get_endpoint_node(unid, endpoint); | ||
|
||
attribute_store_node_t off_flag_node | ||
= attribute_store_get_first_child_by_type( | ||
endpoint_node, | ||
ATTRIBUTE_COMMAND_CLASS_THERMOSTAT_FAN_MODE_OFF_FLAG); | ||
|
||
// First check the call type. If this is a support check support call, | ||
// we check the attributes | ||
if (call_type == UIC_MQTT_DOTDOT_CALLBACK_TYPE_SUPPORT_CHECK) { | ||
// Check user option automatic_deduction_of_supported_commands | ||
return attribute_store_node_exists(off_flag_node) ? SL_STATUS_OK | ||
: SL_STATUS_FAIL; | ||
} | ||
|
||
thermostat_fan_mode_off_flag_t off_flag = 1; | ||
return attribute_store_set_desired(off_flag_node, | ||
&off_flag, | ||
sizeof(off_flag)); | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// Init and teardown functions | ||
/////////////////////////////////////////////////////////////////////////////// | ||
sl_status_t fan_control_cluster_server_init() | ||
{ | ||
sl_log_debug(LOG_TAG, "FanControl cluster (ZWave) server initialization"); | ||
|
||
// Listen to the BASIC Value attribute is created | ||
uic_mqtt_dotdot_unify_fan_control_turn_off_callback_set( | ||
&zwave_fan_control_turn_off); | ||
|
||
return SL_STATUS_OK; | ||
} |
46 changes: 46 additions & 0 deletions
46
applications/zpc/components/zcl_cluster_servers/src/fan_control_cluster_server.h
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,46 @@ | ||
/****************************************************************************** | ||
* # License | ||
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b> | ||
****************************************************************************** | ||
* The licensor of this software is Silicon Laboratories Inc. Your use of this | ||
* software is governed by the terms of Silicon Labs Master Software License | ||
* Agreement (MSLA) available at | ||
* www.silabs.com/about-us/legal/master-software-license-agreement. This | ||
* software is distributed to you in Source Code format and is governed by the | ||
* sections of the MSLA applicable to Source Code. | ||
* | ||
*****************************************************************************/ | ||
|
||
/** | ||
* @defgroup zpc_on_off_cluster_mapper ZPC Fan Control | ||
* @ingroup dotdot_mapper | ||
* @brief Maps OnOff Cluster incoming Commands to attribute modifications. | ||
* | ||
* @{ | ||
*/ | ||
|
||
#ifndef FAN_CONTROL_CLUSTER_SERVER_H | ||
#define FAN_CONTROL_CLUSTER_SERVER_H | ||
|
||
// Generic includes | ||
#include "sl_status.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief Initialize the FanControl cluster server | ||
* | ||
* @returns true on success | ||
* @returns false on failure | ||
* | ||
*/ | ||
sl_status_t fan_control_cluster_server_init(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif //FAN_CONTROL_CLUSTER_SERVER_H | ||
/** @} end fan_control_cluster_server */ |
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
110 changes: 110 additions & 0 deletions
110
applications/zpc/components/zcl_cluster_servers/test/fan_control_cluster_server_test.c
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,110 @@ | ||
/****************************************************************************** | ||
* # License | ||
* <b>Copyright 2022 Silicon Laboratories Inc. www.silabs.com</b> | ||
****************************************************************************** | ||
* The licensor of this software is Silicon Laboratories Inc. Your use of this | ||
* software is governed by the terms of Silicon Labs Master Software License | ||
* Agreement (MSLA) available at | ||
* www.silabs.com/about-us/legal/master-software-license-agreement. This | ||
* software is distributed to you in Source Code format and is governed by the | ||
* sections of the MSLA applicable to Source Code. | ||
* | ||
*****************************************************************************/ | ||
#include "fan_control_cluster_server.h" | ||
#include "unify_dotdot_attribute_store.h" | ||
#include "unity.h" | ||
|
||
// Unify components | ||
#include "datastore.h" | ||
#include "attribute_store_fixt.h" | ||
#include "attribute_store_helper.h" | ||
#include "unify_dotdot_defined_attribute_types.h" | ||
#include "dotdot_mqtt_mock.h" | ||
|
||
// ZPC Components | ||
#include "zwave_unid.h" | ||
#include "zwave_command_class_thermostat_fan_types.h" | ||
|
||
// Test helpers | ||
#include "zpc_attribute_store_test_helper.h" | ||
#include "attribute_store_defined_attribute_types.h" | ||
|
||
uic_mqtt_dotdot_unify_fan_control_turn_off_callback_t | ||
uic_mqtt_dotdot_fan_control_turn_off_callback; | ||
|
||
void uic_mqtt_dotdot_fan_control_turn_off_callback_set_stub( | ||
const uic_mqtt_dotdot_unify_fan_control_turn_off_callback_t callback, | ||
int cmock_num_calls) | ||
{ | ||
uic_mqtt_dotdot_fan_control_turn_off_callback = callback; | ||
} | ||
|
||
/// Setup the test suite (called once before all test_xxx functions are called) | ||
void suiteSetUp() | ||
{ | ||
datastore_init(":memory:"); | ||
attribute_store_init(); | ||
} | ||
|
||
/// Teardown the test suite (called once after all test_xxx functions are called) | ||
int suiteTearDown(int num_failures) | ||
{ | ||
attribute_store_teardown(); | ||
datastore_teardown(); | ||
return num_failures; | ||
} | ||
|
||
/// Called before each and every test | ||
void setUp() | ||
{ | ||
zpc_attribute_store_test_helper_create_network(); | ||
uic_mqtt_dotdot_unify_fan_control_turn_off_callback_set_Stub( | ||
&uic_mqtt_dotdot_fan_control_turn_off_callback_set_stub); | ||
|
||
// Call init | ||
TEST_ASSERT_EQUAL(SL_STATUS_OK, fan_control_cluster_server_init()); | ||
} | ||
|
||
/// Called after each and every test | ||
void tearDown() | ||
{ | ||
attribute_store_delete_node(attribute_store_get_root()); | ||
} | ||
|
||
void test_fan_control_command_mapping() | ||
{ | ||
TEST_ASSERT_NOT_NULL(uic_mqtt_dotdot_fan_control_turn_off_callback); | ||
|
||
TEST_ASSERT_EQUAL(SL_STATUS_FAIL, | ||
uic_mqtt_dotdot_fan_control_turn_off_callback( | ||
supporting_node_unid, | ||
endpoint_id, | ||
UIC_MQTT_DOTDOT_CALLBACK_TYPE_SUPPORT_CHECK)); | ||
|
||
attribute_store_node_t off_node = attribute_store_add_node( | ||
ATTRIBUTE_COMMAND_CLASS_THERMOSTAT_FAN_MODE_OFF_FLAG, | ||
endpoint_id_node); | ||
|
||
// test support | ||
TEST_ASSERT_EQUAL(SL_STATUS_OK, | ||
uic_mqtt_dotdot_fan_control_turn_off_callback( | ||
supporting_node_unid, | ||
endpoint_id, | ||
UIC_MQTT_DOTDOT_CALLBACK_TYPE_SUPPORT_CHECK)); | ||
// Test callback | ||
TEST_ASSERT_EQUAL(SL_STATUS_OK, | ||
uic_mqtt_dotdot_fan_control_turn_off_callback( | ||
supporting_node_unid, | ||
endpoint_id, | ||
UIC_MQTT_DOTDOT_CALLBACK_TYPE_NORMAL)); | ||
|
||
thermostat_fan_mode_off_flag_t off_flag = 0; | ||
|
||
TEST_ASSERT_EQUAL_MESSAGE( | ||
SL_STATUS_OK, | ||
attribute_store_get_desired(off_node, &off_flag, sizeof(off_flag)), | ||
"Can't get Off flag value"); | ||
|
||
// Test value | ||
TEST_ASSERT_EQUAL(1, off_flag); | ||
} |
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
35 changes: 35 additions & 0 deletions
35
...ot_attribute_store/src/unify_dotdot_attribute_store_command_callbacks_zwave_fan_control.h
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,35 @@ | ||
/****************************************************************************** | ||
* # License | ||
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b> | ||
****************************************************************************** | ||
* The licensor of this software is Silicon Laboratories Inc. Your use of this | ||
* software is governed by the terms of Silicon Labs Master Software License | ||
* Agreement (MSLA) available at | ||
* www.silabs.com/about-us/legal/master-software-license-agreement. This | ||
* software is distributed to you in Source Code format and is governed by the | ||
* sections of the MSLA applicable to Source Code. | ||
* | ||
*****************************************************************************/ | ||
|
||
#ifndef ZWAVE_FAN_CONTROL_CLUSTER_MAPPER_H | ||
#define ZWAVE_FAN_CONTROL_CLUSTER_MAPPER_H | ||
|
||
// Generic includes | ||
#include <stdbool.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief Initialize the Zwave Fan Control cluster mapper | ||
* | ||
*/ | ||
void zwave_fan_control_cluster_mapper_init(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif //ZWAVE_FAN_CONTROL_CLUSTER_MAPPER_H | ||
/** @} end unify_cluster_mapper */ |
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